update test

This commit is contained in:
ToruNiina
2017-04-19 13:38:01 +09:00
parent 1c5c0e8572
commit a784e31d0c

View File

@@ -14,7 +14,12 @@ int main()
std::cout << "v2: " << v2.type() << " = " << v2.cast<toml::value_t::Boolean>() << std::endl; std::cout << "v2: " << v2.type() << " = " << v2.cast<toml::value_t::Boolean>() << std::endl;
std::cout << "v3: " << v3.type() << " = " << v3.cast<toml::value_t::Float>() << std::endl; std::cout << "v3: " << v3.type() << " = " << v3.cast<toml::value_t::Float>() << std::endl;
std::cout << "v4: " << v4.type() << " = " << v4.cast<toml::value_t::String>() << std::endl; std::cout << "v4: " << v4.type() << " = " << v4.cast<toml::value_t::String>() << std::endl;
v1.reset(f); v1.cast<toml::value_t::Integer>() += 1;
std::cout << "v1: " << v1.type() << " = " << v1.cast<toml::value_t::Integer>() << std::endl;
v4.cast<toml::value_t::String>() += " piyo";
std::cout << "v4: " << v4.type() << " = " << v4.cast<toml::value_t::String>() << std::endl;
v1 = f;
std::cout << "v1: " << v1.type() << " = " << v1.cast<toml::value_t::Float>() << std::endl; std::cout << "v1: " << v1.type() << " = " << v1.cast<toml::value_t::Float>() << std::endl;
toml::Table tab; toml::Table tab;
@@ -31,9 +36,38 @@ int main()
arr.emplace_back(5); arr.emplace_back(5);
toml::value v5(tab); toml::value v5(tab);
std::cout << "v5: " << v5.type() << std::endl; std::cout << "v5: " << v5.type() << " = {" << std::endl;
const auto& v5t = v5.cast<toml::value_t::Table>();
std::cout << "v5t[v1] = " << v5t.at("v1").cast<toml::value_t::Float>() << std::endl;
std::cout << "v5t[v2] = " << v5t.at("v2").cast<toml::value_t::Boolean>() << std::endl;
std::cout << "v5t[v3] = " << v5t.at("v3").cast<toml::value_t::Float>() << std::endl;
std::cout << "v5t[v4] = " << v5t.at("v4").cast<toml::value_t::String>() << std::endl;
std::cout << "}" << std::endl;
toml::value v6(arr); toml::value v6(arr);
std::cout << "v6: " << v6.type() << std::endl; std::cout << "v6: " << v6.type() << " = ";
for(auto&& item : v6.cast<toml::value_t::Array>())
{
std::cout << item.cast<toml::value_t::Integer>() << ", ";
}
std::cout << std::endl;
std::string piyo("piyo");
std::swap(v4.cast<toml::value_t::String>(), piyo);
std::cout << "v4: " << v4.type() << " = " << v4.cast<toml::value_t::String>() << std::endl;
toml::value v7(v4);
std::cout << "v7: " << v7.type() << " = " << v7.cast<toml::value_t::String>() << std::endl;
toml::value v8(std::move(v4));
std::cout << "v8: " << v8.type() << " = " << v8.cast<toml::value_t::String>() << std::endl;
std::cout << toml::is_castable<int, toml::value_t::Integer>::value << std::endl;
std::cout << toml::is_castable<std::vector<int>, toml::value_t::Array>::value << std::endl;
std::cout << toml::is_castable<int[5], toml::value_t::Array>::value << std::endl;
std::cout << toml::is_castable<std::map<std::string, int>, toml::value_t::Table>::value << std::endl;
std::cout << toml::is_castable<int, toml::value_t::Table>::value << std::endl;
std::cout << toml::is_castable<std::map<int, std::string>, toml::value_t::Table>::value << std::endl;
return 0; return 0;
} }