From bf5999044b8c87c014098f588517c2c946103623 Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Tue, 2 Apr 2019 12:55:22 +0200 Subject: COMMON: add test for Common::isPunct --- test/common/util.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/common/util.h b/test/common/util.h index e195f13a84..d109d5becb 100644 --- a/test/common/util.h +++ b/test/common/util.h @@ -234,4 +234,20 @@ class UtilTestSuite : public CxxTest::TestSuite { } } } + void test_is_punct() { + // isPunct should return true if the input is a punctation ascii char. + for (int c = 0; c < 255; c++) { + if (c >= 33 && c <= 47) { + TS_ASSERT_EQUALS(Common::isPunct(c), 1); + } else if (c >= 58 && c <= 64) { + TS_ASSERT_EQUALS(Common::isPunct(c), 1); + } else if (c >= 91 && c <= 96) { + TS_ASSERT_EQUALS(Common::isPunct(c), 1); + } else if (c >= 123 && c <= 126) { + TS_ASSERT_EQUALS(Common::isPunct(c), 1); + } else { + TS_ASSERT_EQUALS(Common::isPunct(c), 0); + } + } + } }; -- cgit v1.2.3