@@ -3361,6 +3361,116 @@ int main(int argc, const char* argv[]) {
33613361 return runner.runCommandLine (argc, argv);
33623362}
33633363
3364+ struct TemplatedAs : JsonTest::TestCase {};
3365+
3366+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorCString) {
3367+ Json::Value json = " hello world" ;
3368+ JSONTEST_ASSERT_STRING_EQUAL (json.asCString (), json.as <const char *>());
3369+ }
3370+
3371+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorString) {
3372+ Json::Value json = " hello world" ;
3373+ JSONTEST_ASSERT_STRING_EQUAL (json.asString (), json.as <Json::String>());
3374+ }
3375+
3376+ #ifdef JSON_USE_CPPTL
3377+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorConstString) {
3378+ Json::Value json = " hello world" ;
3379+ JSONTEST_ASSERT_STRING_EQUAL (json.asConstString (), json.as <CppTL::ConstString>());
3380+ }
3381+ #endif
3382+
3383+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorInt) {
3384+ Json::Value json = Json::Int (64 );
3385+ JSONTEST_ASSERT_EQUAL (json.asInt (), json.as <Json::Int>());
3386+ }
3387+
3388+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorUInt) {
3389+ Json::Value json = Json::UInt (64 );
3390+ JSONTEST_ASSERT_EQUAL (json.asUInt (), json.as <Json::UInt>());
3391+ }
3392+
3393+ #if defined(JSON_HAS_INT64)
3394+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorInt64) {
3395+ Json::Value json = Json::Int64 (64 );
3396+ JSONTEST_ASSERT_EQUAL (json.asUInt64 (), json.as <Json::Int64>());
3397+ }
3398+
3399+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorUInt64) {
3400+ Json::Value json = Json::UInt64 (64 );
3401+ JSONTEST_ASSERT_EQUAL (json.asUInt64 (), json.as <Json::UInt64>());
3402+ }
3403+ #endif // if defined(JSON_HAS_INT64)
3404+
3405+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorLargestInt) {
3406+ Json::Value json = Json::LargestInt (64 );
3407+ JSONTEST_ASSERT_EQUAL (json.asLargestInt (), json.as <Json::LargestInt>());
3408+ }
3409+
3410+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorLargestUInt) {
3411+ Json::Value json = Json::LargestUInt (64 );
3412+ JSONTEST_ASSERT_EQUAL (json.asLargestUInt (), json.as <Json::LargestUInt>());
3413+ }
3414+
3415+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorFloat) {
3416+ Json::Value json = float (69.69 );
3417+ JSONTEST_ASSERT_EQUAL (json.asFloat (), json.as <float >());
3418+ }
3419+
3420+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorDouble) {
3421+ Json::Value json = double (69.69 );
3422+ JSONTEST_ASSERT_EQUAL (json.asDouble (), json.as <double >());
3423+ }
3424+
3425+ JSONTEST_FIXTURE_LOCAL (TemplatedAs, equalBehaviorBool) {
3426+ Json::Value jsonTrue = true ;
3427+ Json::Value jsonFalse = false ;
3428+ JSONTEST_ASSERT_EQUAL (jsonTrue.asBool (), jsonTrue.as <bool >());
3429+ JSONTEST_ASSERT_EQUAL (jsonFalse.asBool (), jsonFalse.as <bool >());
3430+ }
3431+
3432+ struct TemplatedIs : JsonTest::TestCase {};
3433+
3434+ JSONTEST_FIXTURE_LOCAL (TemplatedIs, equalBehaviorIsBool) {
3435+ Json::Value json = true ;
3436+ JSONTEST_ASSERT_EQUAL (json.isBool (), json.is <bool >());
3437+ }
3438+
3439+ JSONTEST_FIXTURE_LOCAL (TemplatedIs, equalBehaviorIsInt) {
3440+ Json::Value json = 142 ;
3441+ JSONTEST_ASSERT_EQUAL (json.isInt (), json.is <Json::Int>());
3442+ }
3443+
3444+ JSONTEST_FIXTURE_LOCAL (TemplatedIs, equalBehaviorIsInt64) {
3445+ Json::Value json = 142 ;
3446+ JSONTEST_ASSERT_EQUAL (json.isInt64 (), json.is <Json::Int64>());
3447+ }
3448+
3449+ JSONTEST_FIXTURE_LOCAL (TemplatedIs, equalBehaviorIsUInt) {
3450+ Json::Value json = 142 ;
3451+ JSONTEST_ASSERT_EQUAL (json.isUInt (), json.is <Json::UInt>());
3452+ }
3453+
3454+ JSONTEST_FIXTURE_LOCAL (TemplatedIs, equalBehaviorIsUInt64) {
3455+ Json::Value json = 142 ;
3456+ JSONTEST_ASSERT_EQUAL (json.isUInt64 (), json.is <Json::UInt64>());
3457+ }
3458+
3459+ JSONTEST_FIXTURE_LOCAL (TemplatedIs, equalBehaviorIsDouble) {
3460+ Json::Value json = 40.63 ;
3461+ JSONTEST_ASSERT_EQUAL (json.isDouble (), json.is <double >());
3462+ }
3463+
3464+ JSONTEST_FIXTURE_LOCAL (TemplatedIs, equalBehaviorIsCString) {
3465+ Json::Value json = " hello world" ;
3466+ JSONTEST_ASSERT_EQUAL (json.isString (), json.is <const char *>());
3467+ }
3468+
3469+ JSONTEST_FIXTURE_LOCAL (TemplatedIs, equalBehaviorIsString) {
3470+ Json::Value json = " hello world" ;
3471+ JSONTEST_ASSERT_EQUAL (json.isString (), json.is <Json::String>());
3472+ }
3473+
33643474#if defined(__GNUC__)
33653475#pragma GCC diagnostic pop
33663476#endif
0 commit comments