%description: Test opp_strcmp(). nullptr should be equivalent to "". %global: inline std::string tostr(const char *s) { return s==nullptr ? "nullptr" : std::string("\"") + s + "\""; } %activity: const char *a[] = {nullptr, "", "alma", "banan"}; for (int i=0; i<4; i++) for (int j=0; j<4; j++) EV << "opp_strcmp(" << tostr(a[i]) << ", " << tostr(a[j]) << ") ==> " << opp_strcmp(a[i], a[j]) << endl; // strcmp may return the difference of the ASCII codes instead of 0 or 1 (on MAC for example) %subst: /98/1/ %subst: /97/1/ %contains: stdout opp_strcmp(nullptr, nullptr) ==> 0 opp_strcmp(nullptr, "") ==> 0 opp_strcmp(nullptr, "alma") ==> -1 opp_strcmp(nullptr, "banan") ==> -1 opp_strcmp("", nullptr) ==> 0 opp_strcmp("", "") ==> 0 opp_strcmp("", "alma") ==> -1 opp_strcmp("", "banan") ==> -1 opp_strcmp("alma", nullptr) ==> 1 opp_strcmp("alma", "") ==> 1 opp_strcmp("alma", "alma") ==> 0 opp_strcmp("alma", "banan") ==> -1 opp_strcmp("banan", nullptr) ==> 1 opp_strcmp("banan", "") ==> 1 opp_strcmp("banan", "alma") ==> 1 opp_strcmp("banan", "banan") ==> 0