MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / test_literal

Function test_literal

unittests/integer_literal_test.cpp:17–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16template<typename T>
17bool test_literal(T val, const std::string &str, bool use_boxed_number = false)
18{
19 std::cout << '(' << str << ") Comparing : C++ '" << val;
20 chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(),create_chaiscript_parser());
21
22 // Note, after applying the `-` it's possible that chaiscript has internally converted
23 // between two equivalently sized types (ie, unsigned long and unsigned long long on a 64bit system)
24 // so we're going to allow some leeway with the signed tests
25 T val2 = [&](){
26 if (!use_boxed_number) {
27 return chai.eval<T>(str);
28 } else {
29 return chai.eval<chaiscript::Boxed_Number>(str).get_as_checked<T>();
30 }
31 }();
32
33 std::cout << "' chai '" << val2 << "'\n";
34 return val == val2;
35}
36
37int main()
38{

Callers 1

mainFunction · 0.85

Calls 2

create_chaiscript_stdlibFunction · 0.85
create_chaiscript_parserFunction · 0.85

Tested by

no test coverage detected