// -*- mode: c++; c-basic-offset: 2; -*- #include "common.hh" #include "test.hh" #include "strings.hh" namespace { bool test_trim(char const* expected, char const* input) { ASSERT_EQ(expected, Strings::trim(input)); return true; } bool test_quote(char const* expected, char const* input) { ASSERT_EQ(expected, Strings::quote(input)); return true; } bool test_unquote(char const* expected, char const* input) { ASSERT_EQ(expected, Strings::unquote(input)); return true; } } // namespace int main(void) { BEFORE; RUN(test_trim("", "")); RUN(test_trim("foo", "foo")); RUN(test_trim("foo", " foo")); RUN(test_trim("foo", " foo ")); RUN(test_trim("foo", " foo ")); RUN(test_trim("", " ")); RUN(test_trim("", " ")); RUN(test_trim("foo bar", "foo bar")); RUN(test_trim("foo bar", " foo bar ")); RUN(test_quote("\"\"", "")); RUN(test_quote("\"'\"", "'")); RUN(test_quote("\"\\\"\"", "\"")); RUN(test_quote("\"\\\\\"", "\\")); RUN(test_quote("\"foo\"", "foo")); RUN(test_quote("\"\\\"fo\\\"o\"", "\"fo\"o")); RUN(test_quote("\"f\\\"o\\\"o\"", "f\"o\"o")); RUN(test_quote("\"\\\"foo\\\"\"", "\"foo\"")); RUN(test_unquote("", "\"\"")); RUN(test_unquote("'", "\"'\"")); RUN(test_unquote("\"", "\"\\\"\"")); RUN(test_unquote("\\", "\"\\\\\"")); RUN(test_unquote("foo", "\"foo\"")); RUN(test_unquote("\"fo\"o", "\"\\\"fo\\\"o\"")); RUN(test_unquote("f\"o\"o", "\"f\\\"o\\\"o\"")); RUN(test_unquote("\"foo\"", "\"\\\"foo\\\"\"")); AFTER; }