Skip to content
This repository has been archived by the owner on Apr 22, 2019. It is now read-only.

Commit

Permalink
Add Variant map comparation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OlehKulykov committed Aug 19, 2015
1 parent 8867dca commit 90e4db8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions fayecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* - Refactor websocket connection method and remove unused string data copying.
* - Variant holder structure modifications and remove C casting.
* - iOS Swift example application.
* - Fix REVariantMap comparation.
*
* Changes on version 0.1.13:
* - Objective-C client ARC mode only, of cource dec. speed, but no need to controll delegate pointer during deallocating.
Expand Down
10 changes: 10 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ target_link_libraries(test_fayecpp_header fayecpp_static websockets jansson)
add_test(test_fayecpp_header test_fayecpp_header)


add_executable(test_fayecpp_variantmessage test_fayecpp_variantmessage.cpp)
set_property(TARGET test_fayecpp_variantmessage APPEND PROPERTY COMPILE_FLAGS -DFAYECPP_STATIC)
target_link_libraries(test_fayecpp_variantmessage fayecpp_static websockets jansson)
add_test(test_fayecpp_variantmessage test_fayecpp_variantmessage)


add_executable(test_fayecpp_init test_fayecpp_init.cpp)
set_property(TARGET test_fayecpp_init APPEND PROPERTY COMPILE_FLAGS -DFAYECPP_STATIC)
target_link_libraries(test_fayecpp_init fayecpp_static websockets jansson)
Expand All @@ -51,18 +57,21 @@ add_test(test_fayecpp_connect test_fayecpp_connect)

if(HAVE_PTHREAD_H)
target_link_libraries(test_fayecpp_header pthread)
target_link_libraries(test_fayecpp_variantmessage pthread)
target_link_libraries(test_fayecpp_init pthread)
target_link_libraries(test_fayecpp_connect pthread)
endif(HAVE_PTHREAD_H)

if(HAVE_COREFOUNDATION_FRAMEWORK)
target_link_libraries(test_fayecpp_header ${COREFOUNDATION_FRAMEWORK})
target_link_libraries(test_fayecpp_variantmessage ${COREFOUNDATION_FRAMEWORK})
target_link_libraries(test_fayecpp_init ${COREFOUNDATION_FRAMEWORK})
target_link_libraries(test_fayecpp_connect ${COREFOUNDATION_FRAMEWORK})
endif(HAVE_COREFOUNDATION_FRAMEWORK)

if(MINGW)
target_link_libraries(test_fayecpp_header ws2_32)
target_link_libraries(test_fayecpp_variantmessage ws2_32)
target_link_libraries(test_fayecpp_init ws2_32)
target_link_libraries(test_fayecpp_connect ws2_32)
endif(MINGW)
Expand All @@ -75,6 +84,7 @@ endif(HAVE_CURL_CURL_H)


install(TARGETS test_fayecpp_header DESTINATION bin)
install(TARGETS test_fayecpp_variantmessage DESTINATION bin)
install(TARGETS test_fayecpp_init DESTINATION bin)
install(TARGETS test_fayecpp_connect DESTINATION bin)

Expand Down
30 changes: 30 additions & 0 deletions test/test_fayecpp_variantmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,22 @@ using namespace FayeCpp;

int testVariantMessage1()
{
if (REVariant().isEqualToVariant("Hello")) return 1;
if (REVariant().isEqualToVariant(true)) return 1;
if (!REVariant().isEqualToVariant(REVariant())) return 1;

REVariant var1("Hello");

if (!var1.isEqualToVariant("Hello")) return 1;
if (var1.isEqualToVariant("Hello1")) return 2;

if (!var1.isEqualToVariant(L"Hello")) return 1;
if (var1.isEqualToVariant(L"Hello1")) return 2;

var1 = L"Привет";
if (!var1.isEqualToVariant(L"Привет")) return 1;
if (var1.isEqualToVariant(L"Привет 1")) return 2;

REVariantList list1;
list1 += 1;
list1 += true;
Expand All @@ -54,6 +65,8 @@ int testVariantMessage1()
list2 += 1;

if (!list1.isEqualToList(list2)) return 3;
if (!REVariantList().isEqualToList(REVariantList())) return 1;

var1 = list1;
REVariant var2 = list2;

Expand All @@ -74,6 +87,23 @@ int testVariantMessage1()
if (!map1.isEqualToMap(map2)) return 9;
map2["k2"] = 45;
if (map1.isEqualToMap(map2)) return 10;
if (map1.isEqualToMap(REVariantMap())) return 11;
if (REVariantMap().isEqualToMap(map1)) return 12;
if (!REVariantMap().isEqualToMap(REVariantMap())) return 14;

map1.clear();
map2.clear();
var1 = map1;
var2 = map2;

if (!var1.isEqualToVariant(var2)) return 15;
map1["a"] = 1;
var1 = map1;
if (var1.isEqualToVariant(var2)) return 16;

map2["a"] = 1;
var2 = map2;
if (!var1.isEqualToVariant(var2)) return 17;

return EXIT_SUCCESS;
}
Expand Down

0 comments on commit 90e4db8

Please sign in to comment.