Commit ae538811 authored by Davis King's avatar Davis King

Added more type_safe_union tests.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402807
parent dc086aa7
...@@ -200,6 +200,37 @@ namespace ...@@ -200,6 +200,37 @@ namespace
DLIB_CASSERT(a.get<char>() == 'b',""); DLIB_CASSERT(a.get<char>() == 'b',"");
DLIB_CASSERT(b.get<char>() == 'a',""); DLIB_CASSERT(b.get<char>() == 'a',"");
// -----------
a.get<char>() = 'a';
b.get<std::string>() = "a string";
DLIB_CASSERT(a.is_empty() == false,"");
DLIB_CASSERT(a.contains<char>() == true,"");
DLIB_CASSERT(b.is_empty() == false,"");
DLIB_CASSERT(b.contains<char>() == false,"");
DLIB_CASSERT(a.contains<std::string>() == false,"");
DLIB_CASSERT(b.contains<std::string>() == true,"");
DLIB_CASSERT(a.get<char>() == 'a',"");
DLIB_CASSERT(b.get<std::string>() == "a string","");
swap(a,b);
DLIB_CASSERT(b.is_empty() == false,"");
DLIB_CASSERT(b.contains<char>() == true,"");
DLIB_CASSERT(a.is_empty() == false,"");
DLIB_CASSERT(a.contains<char>() == false,"");
DLIB_CASSERT(b.contains<std::string>() == false,"");
DLIB_CASSERT(a.contains<std::string>() == true,"");
DLIB_CASSERT(b.get<char>() == 'a',"");
DLIB_CASSERT(a.get<std::string>() == "a string","");
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment