From ae0228099fd27dd353f243eadfe74bc1b0145613 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Mon, 24 Apr 2023 20:23:37 +0000 Subject: [PATCH] Maintenance: remove some unit test headers (#1293) When a unit test class is not reused across translation units, merge the class declaration with its implementation and remove the header file. In many cases, these classes are not meant/designed to be reusable that way, and we should not imply otherwise by publishing a header file. Excuse src/tests/testAuth.h until we make that test work again. --- compat/Makefile.am | 3 +- compat/testPreCompiler.cc | 21 +++++- compat/testPreCompiler.h | 33 ---------- lib/Makefile.am | 3 +- lib/tests/testRFC1738.cc | 24 ++++++- lib/tests/testRFC1738.h | 37 ----------- src/Makefile.am | 75 ++++++--------------- src/tests/testACLMaxUserIP.cc | 22 ++++++- src/tests/testACLMaxUserIP.h | 39 ----------- src/tests/testBoilerplate.h | 3 + src/tests/testCacheManager.cc | 22 ++++++- src/tests/testCacheManager.h | 36 ---------- src/tests/testCharacterSet.cc | 24 ++++++- src/tests/testCharacterSet.h | 37 ----------- src/tests/testConfigParser.cc | 20 +++++- src/tests/testConfigParser.h | 33 ---------- src/tests/testDiskIO.cc | 19 +++++- src/tests/testDiskIO.h | 32 --------- src/tests/testEnumIterator.cc | 23 ++++++- src/tests/testEnumIterator.h | 37 ----------- src/tests/testEvent.cc | 29 ++++++++- src/tests/testEvent.h | 42 ------------ src/tests/testEventLoop.cc | 30 ++++++++- src/tests/testEventLoop.h | 43 ------------ src/tests/testHttp1Parser.cc | 30 ++++++++- src/tests/testHttp1Parser.h | 43 ------------ src/tests/testHttpReply.cc | 15 ++++- src/tests/testHttpReply.h | 32 --------- src/tests/testHttpRequest.cc | 24 +++++-- src/tests/testHttpRequest.h | 36 ---------- src/tests/testHttpRequestMethod.cc | 31 ++++++++- src/tests/testHttpRequestMethod.h | 47 -------------- src/tests/testIcmp.cc | 41 +++++++++++- src/tests/testIcmp.h | 54 --------------- src/tests/testIpAddress.cc | 56 +++++++++++++++- src/tests/testIpAddress.h | 71 -------------------- src/tests/testLookupTable.cc | 13 +++- src/tests/testLookupTable.h | 24 ------- src/tests/testMem.cc | 17 ++++- src/tests/testMem.h | 30 --------- src/tests/testNetDb.cc | 14 +++- src/tests/testNetDb.h | 28 -------- src/tests/testPackableStream.cc | 15 ++++- src/tests/testPackableStream.h | 32 --------- src/tests/testRFC1035.cc | 28 +++++++- src/tests/testRFC1035.h | 40 ------------ src/tests/testRefCount.cc | 26 +++++++- src/tests/testRefCount.h | 39 ----------- src/tests/testRock.cc | 35 +++++++++- src/tests/testRock.h | 47 -------------- src/tests/testSBuf.cc | 91 +++++++++++++++++++++++++- src/tests/testSBuf.h | 101 ----------------------------- src/tests/testSBufList.cc | 13 +++- src/tests/testSBufList.h | 26 -------- src/tests/testStatHist.cc | 18 ++++- src/tests/testStatHist.h | 37 ----------- src/tests/testStoreController.cc | 22 ++++++- src/tests/testStoreController.h | 35 ---------- src/tests/testStoreHashIndex.cc | 22 ++++++- src/tests/testStoreHashIndex.h | 35 ---------- src/tests/testString.cc | 27 +++++++- src/tests/testString.h | 39 ----------- src/tests/testTokenizer.cc | 23 ++++++- src/tests/testTokenizer.h | 35 ---------- src/tests/testURL.cc | 25 +++++-- src/tests/testURL.h | 35 ---------- src/tests/testUfs.cc | 21 +++++- src/tests/testUfs.h | 34 ---------- src/tests/testUriScheme.cc | 37 +++++++++-- src/tests/testUriScheme.h | 46 ------------- src/tests/testYesNoNone.cc | 20 +++++- src/tests/testYesNoNone.h | 33 ---------- 72 files changed, 863 insertions(+), 1467 deletions(-) delete mode 100644 compat/testPreCompiler.h delete mode 100644 lib/tests/testRFC1738.h delete mode 100644 src/tests/testACLMaxUserIP.h delete mode 100644 src/tests/testCacheManager.h delete mode 100644 src/tests/testCharacterSet.h delete mode 100644 src/tests/testConfigParser.h delete mode 100644 src/tests/testDiskIO.h delete mode 100644 src/tests/testEnumIterator.h delete mode 100644 src/tests/testEvent.h delete mode 100644 src/tests/testEventLoop.h delete mode 100644 src/tests/testHttp1Parser.h delete mode 100644 src/tests/testHttpReply.h delete mode 100644 src/tests/testHttpRequest.h delete mode 100644 src/tests/testHttpRequestMethod.h delete mode 100644 src/tests/testIcmp.h delete mode 100644 src/tests/testIpAddress.h delete mode 100644 src/tests/testLookupTable.h delete mode 100644 src/tests/testMem.h delete mode 100644 src/tests/testNetDb.h delete mode 100644 src/tests/testPackableStream.h delete mode 100644 src/tests/testRFC1035.h delete mode 100644 src/tests/testRefCount.h delete mode 100644 src/tests/testRock.h delete mode 100644 src/tests/testSBuf.h delete mode 100644 src/tests/testSBufList.h delete mode 100644 src/tests/testStatHist.h delete mode 100644 src/tests/testStoreController.h delete mode 100644 src/tests/testStoreHashIndex.h delete mode 100644 src/tests/testString.h delete mode 100644 src/tests/testTokenizer.h delete mode 100644 src/tests/testURL.h delete mode 100644 src/tests/testUfs.h delete mode 100644 src/tests/testUriScheme.h delete mode 100644 src/tests/testYesNoNone.h diff --git a/compat/Makefile.am b/compat/Makefile.am index 8d23b31bc4..88541c502e 100644 --- a/compat/Makefile.am +++ b/compat/Makefile.am @@ -90,8 +90,7 @@ check_PROGRAMS += testPreCompiler TESTS += testPreCompiler testPreCompiler_SOURCES = \ - testPreCompiler.cc \ - testPreCompiler.h + testPreCompiler.cc testPreCompiler_LDADD= $(LIBCPPUNIT_LIBS) testPreCompiler_LDFLAGS= diff --git a/compat/testPreCompiler.cc b/compat/testPreCompiler.cc index 8b6b073475..2a76fb4e83 100644 --- a/compat/testPreCompiler.cc +++ b/compat/testPreCompiler.cc @@ -7,12 +7,29 @@ */ #include "squid.h" -#include "testPreCompiler.h" #include "unitTestMain.h" #include +#include -CPPUNIT_TEST_SUITE_REGISTRATION( TestPreCompiler ); +/* + * Test the pre-compiler directives used within Squid code actually work. + */ + +class TestPreCompiler : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestPreCompiler); + CPPUNIT_TEST(testIfDef); + CPPUNIT_TEST(testIfDefAnd); + CPPUNIT_TEST(testIfDefOr); + CPPUNIT_TEST_SUITE_END(); + +protected: + void testIfDef(); + void testIfDefAnd(); + void testIfDefOr(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestPreCompiler); /** * Test several ways of defining pre-compiler directives. diff --git a/compat/testPreCompiler.h b/compat/testPreCompiler.h deleted file mode 100644 index 7906dfb478..0000000000 --- a/compat/testPreCompiler.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_COMPAT_TESTS_TESTPRECOMPILER_H -#define SQUID_COMPAT_TESTS_TESTPRECOMPILER_H - -#include - -/* - * Test the pre-compiler directives used within Squid code actually work. - */ - -class TestPreCompiler: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestPreCompiler ); - CPPUNIT_TEST( testIfDef ); - CPPUNIT_TEST( testIfDefAnd ); - CPPUNIT_TEST( testIfDefOr ); - CPPUNIT_TEST_SUITE_END(); - -protected: - void testIfDef(); - void testIfDefAnd(); - void testIfDefOr(); -}; - -#endif /* SQUID_COMPAT_TESTS_TESTPRECOMPILER_H */ - diff --git a/lib/Makefile.am b/lib/Makefile.am index 3d0b929c8e..976cdae2ac 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -74,8 +74,7 @@ TESTS += tests/testRFC1738 check_PROGRAMS += tests/testRFC1738 tests_testRFC1738_SOURCES = \ - tests/testRFC1738.cc \ - tests/testRFC1738.h + tests/testRFC1738.cc tests_testRFC1738_LDADD= \ $(top_builddir)/lib/libmiscencoding.la \ diff --git a/lib/tests/testRFC1738.cc b/lib/tests/testRFC1738.cc index 5fc5d86060..93d715783c 100644 --- a/lib/tests/testRFC1738.cc +++ b/lib/tests/testRFC1738.cc @@ -7,15 +7,35 @@ */ #include "squid.h" -#include "testRFC1738.h" #include "unitTestMain.h" #include +#include /* Being a C library code it is best bodily included and tested with C++ type-safe techniques. */ #include "lib/rfc1738.c" -CPPUNIT_TEST_SUITE_REGISTRATION( TestRfc1738 ); +/** + * Test the URL coder RFC 1738 Engine + */ +class TestRfc1738 : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestRfc1738); + CPPUNIT_TEST(testUrlDecode); + CPPUNIT_TEST(testUrlEncode); + + CPPUNIT_TEST(PercentZeroNullDecoding); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void testUrlDecode(); + void testUrlEncode(); + + // bugs. + void PercentZeroNullDecoding(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestRfc1738); /* Regular Format de-coding tests */ void TestRfc1738::testUrlDecode() diff --git a/lib/tests/testRFC1738.h b/lib/tests/testRFC1738.h deleted file mode 100644 index eedae79593..0000000000 --- a/lib/tests/testRFC1738.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_LIB_TEST_RFC1738_H -#define SQUID_LIB_TEST_RFC1738_H - -#include - -/** - * Test the URL coder RFC 1738 Engine - */ -class TestRfc1738: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestRfc1738 ); - CPPUNIT_TEST( testUrlDecode ); - CPPUNIT_TEST( testUrlEncode ); - - CPPUNIT_TEST( PercentZeroNullDecoding ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void testUrlDecode(); - void testUrlEncode(); - - // bugs. - void PercentZeroNullDecoding(); -}; - -#endif /* SQUID_LIB_TEST_RFC1738_H */ - diff --git a/src/Makefile.am b/src/Makefile.am index 9cf56dfcba..c6b84867c9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -785,8 +785,7 @@ tests_testRandomUuid_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testMem tests_testMem_SOURCES = \ - tests/testMem.cc \ - tests/testMem.h + tests/testMem.cc nodist_tests_testMem_SOURCES = \ tests/stub_libtime.cc tests_testMem_LDADD = \ @@ -801,8 +800,7 @@ tests_testMem_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testCharacterSet tests_testCharacterSet_SOURCES = \ - tests/testCharacterSet.cc \ - tests/testCharacterSet.h + tests/testCharacterSet.cc nodist_tests_testCharacterSet_SOURCES = \ base/CharacterSet.h tests_testCharacterSet_LDADD = \ @@ -828,8 +826,7 @@ tests_testClpMap_LDADD = \ check_PROGRAMS += tests/testEnumIterator tests_testEnumIterator_SOURCES = \ - tests/testEnumIterator.cc \ - tests/testEnumIterator.h + tests/testEnumIterator.cc nodist_tests_testEnumIterator_SOURCES = \ base/EnumIterator.h tests_testEnumIterator_LDADD = \ @@ -840,8 +837,7 @@ tests_testEnumIterator_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testLookupTable tests_testLookupTable_SOURCES = \ - tests/testLookupTable.cc \ - tests/testLookupTable.h + tests/testLookupTable.cc nodist_tests_testLookupTable_SOURCES = \ base/LookupTable.h \ tests/stub_debug.cc \ @@ -856,8 +852,7 @@ tests_testLookupTable_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testRefCount tests_testRefCount_SOURCES = \ - tests/testRefCount.cc \ - tests/testRefCount.h + tests/testRefCount.cc nodist_tests_testRefCount_SOURCES = \ base/RefCount.h tests_testRefCount_LDADD = \ @@ -868,8 +863,7 @@ tests_testRefCount_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testYesNoNone tests_testYesNoNone_SOURCES = \ - tests/testYesNoNone.cc \ - tests/testYesNoNone.h + tests/testYesNoNone.cc nodist_tests_testYesNoNone_SOURCES = \ tests/stub_SBuf.cc \ base/YesNoNone.h \ @@ -886,9 +880,7 @@ tests_testYesNoNone_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testURL tests_testURL_SOURCES = \ tests/testURL.cc \ - tests/testURL.h \ - tests/testUriScheme.cc \ - tests/testUriScheme.h + tests/testUriScheme.cc nodist_tests_testURL_SOURCES = \ tests/stub_HelperChildConfig.cc \ tests/stub_HttpHeader.cc \ @@ -919,8 +911,7 @@ tests_testURL_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testDns tests_testDns_SOURCES = \ - tests/testRFC1035.cc \ - tests/testRFC1035.h + tests/testRFC1035.cc nodist_tests_testDns_SOURCES= tests_testDns_LDADD = \ dns/libdns.la \ @@ -933,8 +924,7 @@ tests_testDns_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testTokenizer tests_testTokenizer_SOURCES = \ - tests/testTokenizer.cc \ - tests/testTokenizer.h + tests/testTokenizer.cc nodist_tests_testTokenizer_SOURCES = \ tests/stub_StatHist.cc \ tests/stub_debug.cc \ @@ -954,7 +944,6 @@ tests_testTokenizer_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testSBuf tests_testSBuf_SOURCES = \ tests/testSBuf.cc \ - tests/testSBuf.h \ tests/SBufFindTest.cc \ tests/SBufFindTest.h nodist_tests_testSBuf_SOURCES = \ @@ -971,8 +960,7 @@ tests_testSBuf_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testSBufList tests_testSBufList_SOURCES = \ - tests/testSBufList.cc \ - tests/testSBufList.h + tests/testSBufList.cc nodist_tests_testSBufList_SOURCES = \ tests/stub_StatHist.cc \ tests/stub_debug.cc \ @@ -987,8 +975,7 @@ tests_testSBufList_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testString tests_testString_SOURCES = \ - tests/testString.cc \ - tests/testString.h + tests/testString.cc nodist_tests_testString_SOURCES = \ tests/stub_SBuf.cc \ String.cc \ @@ -1054,7 +1041,6 @@ tests_testRock_SOURCES = \ ResolvedPeers.cc \ ResolvedPeers.h \ tests/testRock.cc \ - tests/testRock.h \ StatCounters.cc \ StatCounters.h \ tests/stub_StatHist.cc \ @@ -1169,7 +1155,6 @@ tests_testRock_LDFLAGS = $(AM_CPPFLAGS) $(LIBADD_DL) else EXTRA_DIST += \ tests/testRock.cc \ - tests/testRock.h \ tests/testStoreSupport.cc \ tests/testStoreSupport.h endif @@ -1238,7 +1223,6 @@ tests_testUfs_SOURCES = \ Transients.cc \ tests/stub_UdsOp.cc \ tests/testUfs.cc \ - tests/testUfs.h \ tests/stub_access_log.cc \ tests/stub_cache_cf.cc \ cache_cf.h \ @@ -1347,8 +1331,7 @@ tests_testUfs_LDADD = \ tests_testUfs_LDFLAGS = $(LIBADD_DL) else EXTRA_DIST += \ - tests/testUfs.cc \ - tests/testUfs.h + tests/testUfs.cc endif ## Tests of store/* and Store objects @@ -1393,7 +1376,6 @@ tests_testStore_SOURCES = \ Notes.cc \ Notes.h \ tests/testPackableStream.cc \ - tests/testPackableStream.h \ Parsing.cc \ tests/stub_Port.cc \ RemovalPolicy.cc \ @@ -1406,10 +1388,8 @@ tests_testStore_SOURCES = \ tests/testStore.cc \ tests/testStore.h \ tests/testStoreController.cc \ - tests/testStoreController.h \ StoreFileSystem.cc \ tests/testStoreHashIndex.cc \ - tests/testStoreHashIndex.h \ StoreIOState.cc \ tests/testStoreSupport.cc \ tests/testStoreSupport.h \ @@ -1531,7 +1511,6 @@ tests_testDiskIO_SOURCES = \ ConfigOption.cc \ ConfigParser.cc \ tests/testDiskIO.cc \ - tests/testDiskIO.h \ tests/stub_ETag.cc \ EventLoop.cc \ FadingCounter.cc \ @@ -1696,8 +1675,7 @@ tests_testDiskIO_LDFLAGS = $(LIBADD_DL) if ENABLE_AUTH check_PROGRAMS += tests/testACLMaxUserIP tests_testACLMaxUserIP_SOURCES = \ - tests/testACLMaxUserIP.cc \ - tests/testACLMaxUserIP.h + tests/testACLMaxUserIP.cc nodist_tests_testACLMaxUserIP_SOURCES = \ tests/stub_CachePeer.cc \ ConfigParser.cc \ @@ -1740,8 +1718,7 @@ tests_testACLMaxUserIP_LDADD = \ tests_testACLMaxUserIP_LDFLAGS = $(LIBADD_DL) else EXTRA_DIST += \ - tests/testACLMaxUserIP.cc \ - tests/testACLMaxUserIP.h + tests/testACLMaxUserIP.cc endif ## Tests of http/* and HTTP Protocol objects @@ -1984,7 +1961,6 @@ check_PROGRAMS += tests/testHttp1Parser tests_testHttp1Parser_SOURCES = \ tests/stub_HelperChildConfig.cc \ tests/testHttp1Parser.cc \ - tests/testHttp1Parser.h \ MemBuf.cc \ MemBuf.h \ tests/stub_MemObject.cc \ @@ -2055,7 +2031,6 @@ tests_testHttpReply_SOURCES = \ HttpReply.cc \ tests/testHttpReply.cc \ HttpReply.h \ - tests/testHttpReply.h \ tests/stub_HttpRequest.cc \ MasterXaction.cc \ MasterXaction.h \ @@ -2180,9 +2155,7 @@ tests_testHttpRequest_SOURCES = \ HttpReply.cc \ HttpRequest.cc \ tests/testHttpRequest.cc \ - tests/testHttpRequest.h \ tests/testHttpRequestMethod.cc \ - tests/testHttpRequestMethod.h \ tests/stub_HttpUpgradeProtocolAccess.cc \ IoStats.h \ tests/stub_IpcIoFile.cc \ @@ -2371,8 +2344,7 @@ tests_testHttpRequest_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testIpAddress tests_testIpAddress_SOURCES = \ - tests/testIpAddress.cc \ - tests/testIpAddress.h + tests/testIpAddress.cc nodist_tests_testIpAddress_SOURCES = \ tests/stub_SBuf.cc \ tests/stub_debug.cc \ @@ -2391,8 +2363,7 @@ tests_testIpAddress_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testIcmp # icmp/libicmpcore.la is used by pinger so SHOULD NOT require more dependancies! :-( tests_testIcmp_SOURCES = \ - tests/testIcmp.cc \ - tests/testIcmp.h + tests/testIcmp.cc nodist_tests_testIcmp_SOURCES = \ tests/stub_SBuf.cc \ tests/stub_debug.cc \ @@ -2410,8 +2381,7 @@ tests_testIcmp_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testNetDb tests_testNetDb_SOURCES = \ - tests/testNetDb.cc \ - tests/testNetDb.h + tests/testNetDb.cc nodist_tests_testNetDb_SOURCES = \ tests/stub_SBuf.cc \ tests/stub_debug.cc \ @@ -2444,7 +2414,6 @@ tests_testCacheManager_SOURCES = \ tests/stub_CacheDigest.cc \ CacheDigest.h \ tests/testCacheManager.cc \ - tests/testCacheManager.h \ CachePeer.cc \ CachePeer.h \ ClientInfo.h \ @@ -2675,7 +2644,6 @@ tests_testStatHist_SOURCES = \ StatHist.cc \ tests/testStatHist.cc \ StatHist.h \ - tests/testStatHist.h \ String.cc \ tests/stub_cache_manager.cc \ tests/stub_cbdata.cc \ @@ -2709,8 +2677,7 @@ tests_testStatHist_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testConfigParser tests_testConfigParser_SOURCES = \ - tests/testConfigParser.cc \ - tests/testConfigParser.h + tests/testConfigParser.cc nodist_tests_testConfigParser_SOURCES = \ ConfigParser.cc \ tests/stub_SBuf.cc \ @@ -2732,8 +2699,7 @@ tests_testConfigParser_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testEvent tests_testEvent_SOURCES = \ - tests/testEvent.cc \ - tests/testEvent.h + tests/testEvent.cc nodist_tests_testEvent_SOURCES = \ MemBuf.cc \ tests/stub_SBuf.cc \ @@ -2753,8 +2719,7 @@ tests_testEvent_LDFLAGS = $(LIBADD_DL) check_PROGRAMS += tests/testEventLoop tests_testEventLoop_SOURCES = \ - tests/testEventLoop.cc \ - tests/testEventLoop.h + tests/testEventLoop.cc nodist_tests_testEventLoop_SOURCES = \ EventLoop.cc \ tests/stub_SBuf.cc \ diff --git a/src/tests/testACLMaxUserIP.cc b/src/tests/testACLMaxUserIP.cc index 8d3b2dd98b..e2b610968b 100644 --- a/src/tests/testACLMaxUserIP.cc +++ b/src/tests/testACLMaxUserIP.cc @@ -13,12 +13,32 @@ #include "acl/Acl.h" #include "auth/AclMaxUserIp.h" #include "auth/UserRequest.h" +#include "compat/cppunit.h" #include "ConfigParser.h" -#include "tests/testACLMaxUserIP.h" #include "unitTestMain.h" #include +/* + * demonstration test file, as new idioms are made they will + * be shown in the TestBoilerplate source. + */ + +class TestACLMaxUserIP : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestACLMaxUserIP); + /* note the statement here and then the actual prototype below */ + CPPUNIT_TEST(testDefaults); + CPPUNIT_TEST(testParseLine); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + void testDefaults(); + void testParseLine(); +}; CPPUNIT_TEST_SUITE_REGISTRATION( TestACLMaxUserIP ); /* globals required to resolve link issues */ diff --git a/src/tests/testACLMaxUserIP.h b/src/tests/testACLMaxUserIP.h deleted file mode 100644 index 20bf242c02..0000000000 --- a/src/tests/testACLMaxUserIP.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_ACLMAXUSERIP_H -#define SQUID_SRC_TEST_ACLMAXUSERIP_H - -#if USE_AUTH - -#include "compat/cppunit.h" - -/* - * demonstration test file, as new idioms are made they will - * be shown in the TestBoilerplate source. - */ - -class TestACLMaxUserIP: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestACLMaxUserIP ); - /* note the statement here and then the actual prototype below */ - CPPUNIT_TEST( testDefaults ); - CPPUNIT_TEST( testParseLine ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - void testDefaults(); - void testParseLine(); -}; - -#endif /* USE_AUTH */ -#endif /* SQUID_SRC_TEST_ACLMAXUSERIP_H */ - diff --git a/src/tests/testBoilerplate.h b/src/tests/testBoilerplate.h index 56887e1610..e387f37cdc 100644 --- a/src/tests/testBoilerplate.h +++ b/src/tests/testBoilerplate.h @@ -14,6 +14,9 @@ /* * demonstration test file, as new idioms are made they will * be shown in the TestBoilerplate source. + * + * If a class declaration is only used in one source file, then declare + * that class where it is used instead of adding a dedicated header file. */ class TestBoilerplate: public CPPUNIT_NS::TestFixture diff --git a/src/tests/testCacheManager.cc b/src/tests/testCacheManager.cc index d8d9bfaac6..853bdcdb5e 100644 --- a/src/tests/testCacheManager.cc +++ b/src/tests/testCacheManager.cc @@ -9,12 +9,32 @@ #include "squid.h" #include "anyp/Uri.h" #include "CacheManager.h" +#include "compat/cppunit.h" #include "mgr/Action.h" #include "Store.h" -#include "testCacheManager.h" #include "unitTestMain.h" #include +/* + * test the CacheManager implementation + */ + +class TestCacheManager : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestCacheManager); + CPPUNIT_TEST(testCreate); + CPPUNIT_TEST(testRegister); + CPPUNIT_TEST(testParseUrl); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + void testCreate(); + void testRegister(); + void testParseUrl(); +}; CPPUNIT_TEST_SUITE_REGISTRATION( TestCacheManager ); diff --git a/src/tests/testCacheManager.h b/src/tests/testCacheManager.h deleted file mode 100644 index 08a98aff78..0000000000 --- a/src/tests/testCacheManager.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_CACHEMANAGER_H -#define SQUID_SRC_TEST_CACHEMANAGER_H - -#include "compat/cppunit.h" - -/* - * test the CacheManager implementation - */ - -class TestCacheManager: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestCacheManager ); - CPPUNIT_TEST( testCreate ); - CPPUNIT_TEST( testRegister ); - CPPUNIT_TEST( testParseUrl ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - void testCreate(); - void testRegister(); - void testParseUrl(); -}; - -#endif - diff --git a/src/tests/testCharacterSet.cc b/src/tests/testCharacterSet.cc index 61e125b700..faddaabd24 100644 --- a/src/tests/testCharacterSet.cc +++ b/src/tests/testCharacterSet.cc @@ -8,11 +8,33 @@ #include "squid.h" #include "base/CharacterSet.h" -#include "testCharacterSet.h" +#include "compat/cppunit.h" #include "unitTestMain.h" #include +class TestCharacterSet : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestCharacterSet); + CPPUNIT_TEST(CharacterSetConstruction); + CPPUNIT_TEST(CharacterSetAdd); + CPPUNIT_TEST(CharacterSetAddRange); + CPPUNIT_TEST(CharacterSetEqualityOp); + CPPUNIT_TEST(CharacterSetConstants); + CPPUNIT_TEST(CharacterSetUnion); + CPPUNIT_TEST(CharacterSetSubtract); + CPPUNIT_TEST_SUITE_END(); + +protected: + void CharacterSetConstruction(); + void CharacterSetAdd(); + void CharacterSetAddRange(); + void CharacterSetConstants(); + void CharacterSetUnion(); + void CharacterSetEqualityOp(); + void CharacterSetSubtract(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestCharacterSet ); void diff --git a/src/tests/testCharacterSet.h b/src/tests/testCharacterSet.h deleted file mode 100644 index b2286ead5e..0000000000 --- a/src/tests/testCharacterSet.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_BASE_TESTCHARACTERSET_H -#define SQUID_BASE_TESTCHARACTERSET_H - -#include "compat/cppunit.h" - -class TestCharacterSet: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestCharacterSet ); - CPPUNIT_TEST( CharacterSetConstruction ); - CPPUNIT_TEST( CharacterSetAdd ); - CPPUNIT_TEST( CharacterSetAddRange ); - CPPUNIT_TEST( CharacterSetEqualityOp ); - CPPUNIT_TEST( CharacterSetConstants ); - CPPUNIT_TEST( CharacterSetUnion ); - CPPUNIT_TEST( CharacterSetSubtract ); - CPPUNIT_TEST_SUITE_END(); - -protected: - void CharacterSetConstruction(); - void CharacterSetAdd(); - void CharacterSetAddRange(); - void CharacterSetConstants(); - void CharacterSetUnion(); - void CharacterSetEqualityOp(); - void CharacterSetSubtract(); -}; - -#endif /* SQUID_BASE_TESTCHARACTERSET_H */ - diff --git a/src/tests/testConfigParser.cc b/src/tests/testConfigParser.cc index f896b4324c..40804c7135 100644 --- a/src/tests/testConfigParser.cc +++ b/src/tests/testConfigParser.cc @@ -7,11 +7,29 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "ConfigParser.h" #include "SquidString.h" -#include "tests/testConfigParser.h" #include "unitTestMain.h" +/* + * test the ConfigParser framework + */ + +class TestConfigParser : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestConfigParser); + CPPUNIT_TEST(testParseQuoted); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + bool doParseQuotedTest(const char *, const char *); + void testParseQuoted(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestConfigParser ); int shutting_down = 0; diff --git a/src/tests/testConfigParser.h b/src/tests/testConfigParser.h deleted file mode 100644 index f47de6ab15..0000000000 --- a/src/tests/testConfigParser.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_CONFIG_PARSER_H -#define SQUID_SRC_TEST_CONFIG_PARSER_H - -#include "compat/cppunit.h" - -/* - * test the ConfigParser framework - */ - -class TestConfigParser: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestConfigParser ); - CPPUNIT_TEST( testParseQuoted ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - bool doParseQuotedTest(const char *, const char *); - void testParseQuoted(); -}; - -#endif - diff --git a/src/tests/testDiskIO.cc b/src/tests/testDiskIO.cc index b6a1279b03..b158e2cc1f 100644 --- a/src/tests/testDiskIO.cc +++ b/src/tests/testDiskIO.cc @@ -7,18 +7,35 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "DiskIO/DiskIOModule.h" #include "HttpHeader.h" #include "HttpReply.h" #include "MemObject.h" #include "Store.h" #include "StoreFileSystem.h" -#include "testDiskIO.h" #include "testStoreSupport.h" #include "unitTestMain.h" #include +/* + * test the DiskIO framework + */ + +class TestDiskIO : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestDiskIO); + CPPUNIT_TEST(testFindDefault); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + void testFindDefault(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestDiskIO ); void diff --git a/src/tests/testDiskIO.h b/src/tests/testDiskIO.h deleted file mode 100644 index 6015f05bdc..0000000000 --- a/src/tests/testDiskIO.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_DISKIO_H -#define SQUID_SRC_TEST_DISKIO_H - -#include "compat/cppunit.h" - -/* - * test the DiskIO framework - */ - -class TestDiskIO: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestDiskIO ); - CPPUNIT_TEST( testFindDefault ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - void testFindDefault(); -}; - -#endif - diff --git a/src/tests/testEnumIterator.cc b/src/tests/testEnumIterator.cc index 4d623ec12c..a36eb82762 100644 --- a/src/tests/testEnumIterator.cc +++ b/src/tests/testEnumIterator.cc @@ -7,11 +7,32 @@ */ #include "squid.h" -#include "tests/testEnumIterator.h" +#include "base/EnumIterator.h" +#include "compat/cppunit.h" #include "unitTestMain.h" #include +class TestEnumIterator : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestEnumIterator); + CPPUNIT_TEST(testForwardIter); + CPPUNIT_TEST(testReverseIter); + CPPUNIT_TEST(testBidirectionalIter); + CPPUNIT_TEST(testRangeFor); + CPPUNIT_TEST(testRangeForRange); + CPPUNIT_TEST(testUnsignedEnum); + CPPUNIT_TEST_SUITE_END(); + +protected: + void testForwardIter(); + void testReverseIter(); + void testBidirectionalIter(); + void testRangeFor(); + void testRangeForRange(); + void testUnsignedEnum(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestEnumIterator ); enum class TestEnum { diff --git a/src/tests/testEnumIterator.h b/src/tests/testEnumIterator.h deleted file mode 100644 index a3c32fe8c4..0000000000 --- a/src/tests/testEnumIterator.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_TESTENUMITERATOR_H_ -#define SQUID_TESTENUMITERATOR_H_ - -#include "base/EnumIterator.h" - -#include "compat/cppunit.h" - -class TestEnumIterator: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestEnumIterator ); - CPPUNIT_TEST( testForwardIter ); - CPPUNIT_TEST( testReverseIter ); - CPPUNIT_TEST( testBidirectionalIter ); - CPPUNIT_TEST( testRangeFor ); - CPPUNIT_TEST( testRangeForRange ); - CPPUNIT_TEST( testUnsignedEnum ); - CPPUNIT_TEST_SUITE_END(); - -protected: - void testForwardIter(); - void testReverseIter(); - void testBidirectionalIter(); - void testRangeFor(); - void testRangeForRange(); - void testUnsignedEnum(); -}; - -#endif /* SQUID_TESTENUMITERATOR_H_ */ - diff --git a/src/tests/testEvent.cc b/src/tests/testEvent.cc index ae4b750198..7bf8178ed6 100644 --- a/src/tests/testEvent.cc +++ b/src/tests/testEvent.cc @@ -8,11 +8,38 @@ #include "squid.h" #include "base/AsyncCallQueue.h" +#include "compat/cppunit.h" #include "event.h" #include "MemBuf.h" -#include "tests/testEvent.h" #include "unitTestMain.h" +/* + * test the event module. + */ + +class TestEvent : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestEvent); + CPPUNIT_TEST(testCreate); + CPPUNIT_TEST(testDump); + CPPUNIT_TEST(testFind); + CPPUNIT_TEST(testCheckEvents); + CPPUNIT_TEST(testSingleton); + CPPUNIT_TEST(testCancel); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + void testCreate(); + void testDump(); + void testFind(); + void testCheckEvents(); + void testSingleton(); + void testCancel(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestEvent ); /* init legacy static-initialized modules */ diff --git a/src/tests/testEvent.h b/src/tests/testEvent.h deleted file mode 100644 index d91431cb4c..0000000000 --- a/src/tests/testEvent.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_EVENT_H -#define SQUID_SRC_TEST_EVENT_H - -#include "compat/cppunit.h" - -/* - * test the event module. - */ - -class TestEvent: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestEvent ); - CPPUNIT_TEST( testCreate ); - CPPUNIT_TEST( testDump ); - CPPUNIT_TEST( testFind ); - CPPUNIT_TEST( testCheckEvents ); - CPPUNIT_TEST( testSingleton ); - CPPUNIT_TEST( testCancel ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - void testCreate(); - void testDump(); - void testFind(); - void testCheckEvents(); - void testSingleton(); - void testCancel(); -}; - -#endif - diff --git a/src/tests/testEventLoop.cc b/src/tests/testEventLoop.cc index 782b9612b8..91792a2c14 100644 --- a/src/tests/testEventLoop.cc +++ b/src/tests/testEventLoop.cc @@ -8,13 +8,41 @@ #include "squid.h" #include "AsyncEngine.h" +#include "compat/cppunit.h" #include "EventLoop.h" -#include "tests/testEventLoop.h" #include "time/Engine.h" #include "unitTestMain.h" #include +/* + * test the EventLoop implementation + */ + +class TestEventLoop : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestEventLoop); + CPPUNIT_TEST(testCreate); + CPPUNIT_TEST(testRunOnce); + CPPUNIT_TEST(testEngineTimeout); + CPPUNIT_TEST(testEngineErrors); + CPPUNIT_TEST(testSetTimeService); + CPPUNIT_TEST(testSetPrimaryEngine); + CPPUNIT_TEST_SUITE_END(); + +protected: + void testCreate(); + void testRunOnce(); + void testEngineTimeout(); + void testEngineErrors(); + void testSetTimeService(); + void testSetPrimaryEngine(); + /* TODO: + * test that engine which errors a couple of times, then returns 0, then + * errors 10 times in a row triggers a fail on the 10th time around + */ +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestEventLoop ); void diff --git a/src/tests/testEventLoop.h b/src/tests/testEventLoop.h deleted file mode 100644 index 28e99c9a41..0000000000 --- a/src/tests/testEventLoop.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_EVENTLOOP_H -#define SQUID_SRC_TEST_EVENTLOOP_H - -#include "compat/cppunit.h" - -/* - * test the EventLoop implementation - */ - -class TestEventLoop: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestEventLoop ); - CPPUNIT_TEST( testCreate ); - CPPUNIT_TEST( testRunOnce ); - CPPUNIT_TEST( testEngineTimeout ); - CPPUNIT_TEST( testEngineErrors ); - CPPUNIT_TEST( testSetTimeService ); - CPPUNIT_TEST( testSetPrimaryEngine ); - CPPUNIT_TEST_SUITE_END(); - -protected: - void testCreate(); - void testRunOnce(); - void testEngineTimeout(); - void testEngineErrors(); - void testSetTimeService(); - void testSetPrimaryEngine(); - /* TODO: - * test that engine which errors a couple of times, then returns 0, then - * errors 10 times in a row triggers a fail on the 10th time around - */ -}; - -#endif - diff --git a/src/tests/testHttp1Parser.cc b/src/tests/testHttp1Parser.cc index 7a23b396b2..1c7331069c 100644 --- a/src/tests/testHttp1Parser.cc +++ b/src/tests/testHttp1Parser.cc @@ -13,14 +13,42 @@ #define private public #define protected public +#include "compat/cppunit.h" #include "debug/Stream.h" #include "http/one/RequestParser.h" #include "http/RequestMethod.h" #include "MemBuf.h" #include "SquidConfig.h" -#include "testHttp1Parser.h" #include "unitTestMain.h" +class TestHttp1Parser : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestHttp1Parser); + // object basics are working, just in case. + CPPUNIT_TEST(testParserConstruct); + CPPUNIT_TEST(testDripFeed); + CPPUNIT_TEST(testParseRequestLineMethods); + CPPUNIT_TEST(testParseRequestLineProtocols); + CPPUNIT_TEST(testParseRequestLineTerminators); + CPPUNIT_TEST(testParseRequestLineStrange); + CPPUNIT_TEST(testParseRequestLineInvalid); + CPPUNIT_TEST_SUITE_END(); + +protected: + void globalSetup(); // MemPools init etc. + + void testParserConstruct(); // whether the constructor works + + // request-line unit tests + void testParseRequestLineTerminators(); // terminator detection correct + void testParseRequestLineMethods(); // methoid detection correct + void testParseRequestLineProtocols(); // protocol tokens handled correctly + void testParseRequestLineStrange(); // strange but valid lines accepted + void testParseRequestLineInvalid(); // rejection of invalid lines happens + + void testDripFeed(); // test incremental parse works +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestHttp1Parser ); void diff --git a/src/tests/testHttp1Parser.h b/src/tests/testHttp1Parser.h deleted file mode 100644 index ba53e640b8..0000000000 --- a/src/tests/testHttp1Parser.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TESTS_TESTHTTP1PARSER_H -#define SQUID_SRC_TESTS_TESTHTTP1PARSER_H - -#include "compat/cppunit.h" - -class TestHttp1Parser: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestHttp1Parser ); - // object basics are working, just in case. - CPPUNIT_TEST( testParserConstruct ); - CPPUNIT_TEST( testDripFeed ); - CPPUNIT_TEST( testParseRequestLineMethods ); - CPPUNIT_TEST( testParseRequestLineProtocols ); - CPPUNIT_TEST( testParseRequestLineTerminators ); - CPPUNIT_TEST( testParseRequestLineStrange ); - CPPUNIT_TEST( testParseRequestLineInvalid ); - CPPUNIT_TEST_SUITE_END(); - -protected: - void globalSetup(); // MemPools init etc. - - void testParserConstruct(); // whether the constructor works - - // request-line unit tests - void testParseRequestLineTerminators(); // terminator detection correct - void testParseRequestLineMethods(); // methoid detection correct - void testParseRequestLineProtocols(); // protocol tokens handled correctly - void testParseRequestLineStrange(); // strange but valid lines accepted - void testParseRequestLineInvalid(); // rejection of invalid lines happens - - void testDripFeed(); // test incremental parse works -}; - -#endif - diff --git a/src/tests/testHttpReply.cc b/src/tests/testHttpReply.cc index ec28c57a67..5730b68da8 100644 --- a/src/tests/testHttpReply.cc +++ b/src/tests/testHttpReply.cc @@ -9,13 +9,26 @@ #include "squid.h" #include +#include "compat/cppunit.h" #include "HttpHeader.h" #include "HttpReply.h" #include "mime_header.h" #include "SquidConfig.h" -#include "testHttpReply.h" #include "unitTestMain.h" +class TestHttpReply : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestHttpReply); + CPPUNIT_TEST(testSanityCheckFirstLine); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + void testSanityCheckFirstLine(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestHttpReply ); class SquidConfig Config; diff --git a/src/tests/testHttpReply.h b/src/tests/testHttpReply.h deleted file mode 100644 index 152b294a4a..0000000000 --- a/src/tests/testHttpReply.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_HTTP_REPLY_H -#define SQUID_SRC_TEST_HTTP_REPLY_H - -#include "compat/cppunit.h" - -/* - * test HttpReply - */ - -class TestHttpReply: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestHttpReply ); - CPPUNIT_TEST( testSanityCheckFirstLine ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - void testSanityCheckFirstLine(); -}; - -#endif - diff --git a/src/tests/testHttpRequest.cc b/src/tests/testHttpRequest.cc index 446993ac25..c07821e18c 100644 --- a/src/tests/testHttpRequest.cc +++ b/src/tests/testHttpRequest.cc @@ -7,16 +7,32 @@ */ #include "squid.h" - -#include - +#include "compat/cppunit.h" #include "HttpHeader.h" #include "HttpRequest.h" #include "MasterXaction.h" #include "mime_header.h" -#include "testHttpRequest.h" #include "unitTestMain.h" +#include + +class TestHttpRequest : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestHttpRequest); + CPPUNIT_TEST(testCreateFromUrl); + CPPUNIT_TEST(testIPv6HostColonBug); + CPPUNIT_TEST(testSanityCheckStartLine); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + void testCreateFromUrl(); + void testIPv6HostColonBug(); + void testSanityCheckStartLine(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestHttpRequest ); /** wrapper for testing HttpRequest object private and protected functions */ diff --git a/src/tests/testHttpRequest.h b/src/tests/testHttpRequest.h deleted file mode 100644 index 9c03e2733f..0000000000 --- a/src/tests/testHttpRequest.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_HTTP_REQUEST_H -#define SQUID_SRC_TEST_HTTP_REQUEST_H - -#include "compat/cppunit.h" - -/* - * test HttpRequest - */ - -class TestHttpRequest: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestHttpRequest ); - CPPUNIT_TEST( testCreateFromUrl ); - CPPUNIT_TEST( testIPv6HostColonBug ); - CPPUNIT_TEST( testSanityCheckStartLine ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - void testCreateFromUrl(); - void testIPv6HostColonBug(); - void testSanityCheckStartLine(); -}; - -#endif - diff --git a/src/tests/testHttpRequestMethod.cc b/src/tests/testHttpRequestMethod.cc index 8f781b0170..8d36ed9862 100644 --- a/src/tests/testHttpRequestMethod.cc +++ b/src/tests/testHttpRequestMethod.cc @@ -7,14 +7,39 @@ */ #include "squid.h" -#include - +#include "compat/cppunit.h" #include "http/RequestMethod.h" #include "SquidConfig.h" -#include "testHttpRequestMethod.h" #include +class TestHttpRequestMethod : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestHttpRequestMethod); + CPPUNIT_TEST(testAssignFrommethod_t); + CPPUNIT_TEST(testConstructmethod_t); + CPPUNIT_TEST(testConstructCharStart); + CPPUNIT_TEST(testConstructCharStartEnd); + CPPUNIT_TEST(testDefaultConstructor); + CPPUNIT_TEST(testEqualmethod_t); + CPPUNIT_TEST(testNotEqualmethod_t); + CPPUNIT_TEST(testImage); + CPPUNIT_TEST(testStream); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void testAssignFrommethod_t(); + void testConstructmethod_t(); + void testConstructCharStart(); + void testConstructCharStartEnd(); + void testImage(); + void testDefaultConstructor(); + void testEqualmethod_t(); + void testNotEqualmethod_t(); + void testStream(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestHttpRequestMethod ); /* diff --git a/src/tests/testHttpRequestMethod.h b/src/tests/testHttpRequestMethod.h deleted file mode 100644 index 7f47fb0d40..0000000000 --- a/src/tests/testHttpRequestMethod.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_HTTP_REQUEST_METHOD_H -#define SQUID_SRC_TEST_HTTP_REQUEST_METHOD_H - -#include "compat/cppunit.h" - -/* - * test HttpRequestMethod - */ - -class TestHttpRequestMethod: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestHttpRequestMethod ); - CPPUNIT_TEST( testAssignFrommethod_t ); - CPPUNIT_TEST( testConstructmethod_t ); - CPPUNIT_TEST( testConstructCharStart ); - CPPUNIT_TEST( testConstructCharStartEnd ); - CPPUNIT_TEST( testDefaultConstructor ); - CPPUNIT_TEST( testEqualmethod_t ); - CPPUNIT_TEST( testNotEqualmethod_t ); - CPPUNIT_TEST( testImage ); - CPPUNIT_TEST( testStream ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void testAssignFrommethod_t(); - void testConstructmethod_t(); - void testConstructCharStart(); - void testConstructCharStartEnd(); - void testImage(); - void testDefaultConstructor(); - void testEqualmethod_t(); - void testNotEqualmethod_t(); - void testStream(); -}; - -#endif - diff --git a/src/tests/testIcmp.cc b/src/tests/testIcmp.cc index 5b93c739cc..d6885af74e 100644 --- a/src/tests/testIcmp.cc +++ b/src/tests/testIcmp.cc @@ -9,11 +9,50 @@ #define SQUID_HELPER 1 #include "squid.h" -#include "tests/testIcmp.h" +#include "compat/cppunit.h" #include "unitTestMain.h" #include +#if USE_ICMP + +#include "icmp/Icmp.h" + +class IcmpStub : public Icmp +{ +public: + IcmpStub() {}; + ~IcmpStub() override {}; + int Open() override { return 0; }; + void Close() override {}; + + /// Construct ECHO request + void SendEcho(Ip::Address &, int, const char *, int) override {} + + /// Handle ICMP responses. + void Recv(void) override {}; + + /* methods to relay test data from tester to private methods being tested */ + int testChecksum(unsigned short *ptr, int size) { return CheckSum(ptr, size); }; + int testHops(int ttl) { return ipHops(ttl); }; +}; +#endif + +/** + * test the ICMP base class. + */ +class TestIcmp : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestIcmp); + CPPUNIT_TEST(testChecksum); + CPPUNIT_TEST(testHops); + CPPUNIT_TEST_SUITE_END(); + +protected: + void testChecksum(); + void testHops(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestIcmp ); void diff --git a/src/tests/testIcmp.h b/src/tests/testIcmp.h deleted file mode 100644 index 5cdda1c185..0000000000 --- a/src/tests/testIcmp.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TESTS_TESTICMP_H -#define SQUID_SRC_TESTS_TESTICMP_H - -#include "compat/cppunit.h" - -#if USE_ICMP - -#include "icmp/Icmp.h" - -class IcmpStub: public Icmp -{ -public: - IcmpStub() {}; - ~IcmpStub() override {}; - int Open() override { return 0; }; - void Close() override {}; - - /// Construct ECHO request - void SendEcho(Ip::Address &, int, const char *, int) override {} - - /// Handle ICMP responses. - void Recv(void) override {}; - - /* methods to relay test data from tester to private methods being tested */ - int testChecksum(unsigned short *ptr, int size) { return CheckSum(ptr,size); }; - int testHops(int ttl) { return ipHops(ttl); }; -}; -#endif - -/** - * test the ICMP base class. - */ -class TestIcmp: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestIcmp ); - CPPUNIT_TEST( testChecksum ); - CPPUNIT_TEST( testHops ); - CPPUNIT_TEST_SUITE_END(); - -protected: - void testChecksum(); - void testHops(); -}; - -#endif /* SQUID_SRC_TESTS_TESTICMP_H */ - diff --git a/src/tests/testIpAddress.cc b/src/tests/testIpAddress.cc index bb2cef4d76..9b5d5c970d 100644 --- a/src/tests/testIpAddress.cc +++ b/src/tests/testIpAddress.cc @@ -7,9 +7,9 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "ip/Address.h" #include "ip/tools.h" -#include "tests/testIpAddress.h" #include "unitTestMain.h" #include @@ -25,6 +25,60 @@ #include #endif +/* + * test the IP storage type + */ + +class TestIpAddress : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestIpAddress); + CPPUNIT_TEST(testDefaults); + CPPUNIT_TEST(testInAddrConstructor); + CPPUNIT_TEST(testInAddr6Constructor); + CPPUNIT_TEST(testSockAddrConstructor); + CPPUNIT_TEST(testSockAddr6Constructor); + CPPUNIT_TEST(testHostentConstructor); + CPPUNIT_TEST(testStringConstructor); + CPPUNIT_TEST(testCopyConstructor); + CPPUNIT_TEST(testsetEmpty); + CPPUNIT_TEST(testBooleans); + CPPUNIT_TEST(testAddrInfo); + CPPUNIT_TEST(testtoStr); + CPPUNIT_TEST(testtoUrl_fromInAddr); + CPPUNIT_TEST(testtoUrl_fromSockAddr); + CPPUNIT_TEST(testgetReverseString); + CPPUNIT_TEST(testMasking); + + CPPUNIT_TEST(testBugNullingDisplay); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void testDefaults(); + + void testInAddrConstructor(); + void testInAddr6Constructor(); + void testSockAddrConstructor(); + void testSockAddr6Constructor(); + void testHostentConstructor(); + void testStringConstructor(); + void testCopyConstructor(); + + void testsetEmpty(); + void testBooleans(); + + void testAddrInfo(); + + void testtoStr(); + void testtoUrl_fromInAddr(); + void testtoUrl_fromSockAddr(); + void testgetReverseString(); + void testMasking(); + + // bugs. + void testBugNullingDisplay(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestIpAddress ); void diff --git a/src/tests/testIpAddress.h b/src/tests/testIpAddress.h deleted file mode 100644 index 97d1cac8b4..0000000000 --- a/src/tests/testIpAddress.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_IPADDRESS_H -#define SQUID_SRC_TEST_IPADDRESS_H - -#include "compat/cppunit.h" - -/* - * test the IP storage type - */ - -class TestIpAddress: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestIpAddress ); - CPPUNIT_TEST( testDefaults ); - CPPUNIT_TEST( testInAddrConstructor ); - CPPUNIT_TEST( testInAddr6Constructor ); - CPPUNIT_TEST( testSockAddrConstructor ); - CPPUNIT_TEST( testSockAddr6Constructor ); - CPPUNIT_TEST( testHostentConstructor ); - CPPUNIT_TEST( testStringConstructor ); - CPPUNIT_TEST( testCopyConstructor ); - CPPUNIT_TEST( testsetEmpty ); - CPPUNIT_TEST( testBooleans ); - CPPUNIT_TEST( testAddrInfo ); - CPPUNIT_TEST( testtoStr ); - CPPUNIT_TEST( testtoUrl_fromInAddr ); - CPPUNIT_TEST( testtoUrl_fromSockAddr ); - CPPUNIT_TEST( testgetReverseString ); - CPPUNIT_TEST( testMasking ); - - CPPUNIT_TEST( testBugNullingDisplay ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void testDefaults(); - - void testInAddrConstructor(); - void testInAddr6Constructor(); - void testSockAddrConstructor(); - void testSockAddr6Constructor(); - void testHostentConstructor(); - void testStringConstructor(); - void testCopyConstructor(); - - void testsetEmpty(); - void testBooleans(); - - void testAddrInfo(); - - void testtoStr(); - void testtoUrl_fromInAddr(); - void testtoUrl_fromSockAddr(); - void testgetReverseString(); - void testMasking(); - - // bugs. - void testBugNullingDisplay(); - -}; - -#endif /* SQUID_SRC_TEST_IPADDRESS_H */ - diff --git a/src/tests/testLookupTable.cc b/src/tests/testLookupTable.cc index 306889d247..337fb0d6e0 100644 --- a/src/tests/testLookupTable.cc +++ b/src/tests/testLookupTable.cc @@ -8,10 +8,19 @@ #include "squid.h" #include "base/LookupTable.h" -#include "testLookupTable.h" +#include "compat/cppunit.h" #include "unitTestMain.h" -CPPUNIT_TEST_SUITE_REGISTRATION( TestLookupTable ); +class TestLookupTable : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestLookupTable); + CPPUNIT_TEST(testLookupTableLookup); + CPPUNIT_TEST_SUITE_END(); + +public: + void testLookupTableLookup(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestLookupTable); enum EnumData { ENUM_1, diff --git a/src/tests/testLookupTable.h b/src/tests/testLookupTable.h deleted file mode 100644 index c1da774f43..0000000000 --- a/src/tests/testLookupTable.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_TESTLOOKUPTABLE_H_ -#define SQUID_TESTLOOKUPTABLE_H_ - -#include "compat/cppunit.h" - -class TestLookupTable: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestLookupTable ); - CPPUNIT_TEST( testLookupTableLookup ); - CPPUNIT_TEST_SUITE_END(); -public: - void testLookupTableLookup(); -}; - -#endif /* SQUID_TESTLOOKUPTABLE_H_ */ - diff --git a/src/tests/testMem.cc b/src/tests/testMem.cc index 9fd69ee2df..ba8f5dcfca 100644 --- a/src/tests/testMem.cc +++ b/src/tests/testMem.cc @@ -7,15 +7,28 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "mem/Allocator.h" #include "mem/Pool.h" -#include "tests/testMem.h" #include "unitTestMain.h" #include #include -CPPUNIT_TEST_SUITE_REGISTRATION( TestMem ); +class TestMem : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestMem); + /* note the statement here and then the actual prototype below */ + CPPUNIT_TEST(testMemPool); + CPPUNIT_TEST(testMemProxy); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void testMemPool(); + void testMemProxy(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestMem); class SomethingToAlloc { diff --git a/src/tests/testMem.h b/src/tests/testMem.h deleted file mode 100644 index 83f1ee6aaf..0000000000 --- a/src/tests/testMem.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TESTS_TESTMEM_H -#define SQUID_SRC_TESTS_TESTMEM_H - -#include "compat/cppunit.h" - -class TestMem: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestMem ); - /* note the statement here and then the actual prototype below */ - CPPUNIT_TEST( testMemPool ); - CPPUNIT_TEST( testMemProxy ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void testMemPool(); - void testMemProxy(); -}; - -#endif /* SQUID_SRC_TESTS_TESTMEM_H */ - diff --git a/src/tests/testNetDb.cc b/src/tests/testNetDb.cc index 03a9419af7..26373e2efd 100644 --- a/src/tests/testNetDb.cc +++ b/src/tests/testNetDb.cc @@ -7,11 +7,21 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "icmp/net_db.h" -#include "tests/testNetDb.h" #include "unitTestMain.h" -#include +class TestNetDb : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestNetDb); + /* note the statement here and then the actual prototype below */ + CPPUNIT_TEST(testConstruct); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void testConstruct(); +}; CPPUNIT_TEST_SUITE_REGISTRATION( TestNetDb ); diff --git a/src/tests/testNetDb.h b/src/tests/testNetDb.h deleted file mode 100644 index ca6839c033..0000000000 --- a/src/tests/testNetDb.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TESTS_TESTNETDB_H -#define SQUID_SRC_TESTS_TESTNETDB_H - -#include "compat/cppunit.h" - -class TestNetDb: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestNetDb ); - /* note the statement here and then the actual prototype below */ - CPPUNIT_TEST( testConstruct ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void testConstruct(); -}; - -#endif /* SQUID_SRC_TESTS_TESTNETDB_H */ - diff --git a/src/tests/testPackableStream.cc b/src/tests/testPackableStream.cc index 769b76ff45..8df7758627 100644 --- a/src/tests/testPackableStream.cc +++ b/src/tests/testPackableStream.cc @@ -9,13 +9,26 @@ #include "squid.h" #include "base/PackableStream.h" #include "CapturingStoreEntry.h" +#include "compat/cppunit.h" #include "Store.h" -#include "testPackableStream.h" #include "testStore.h" #include #include +class TestPackableStream : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestPackableStream); + CPPUNIT_TEST(testGetStream); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + void testGetStream(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestPackableStream ); /* init memory pools */ diff --git a/src/tests/testPackableStream.h b/src/tests/testPackableStream.h deleted file mode 100644 index 5549874f03..0000000000 --- a/src/tests/testPackableStream.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TESTS_TESTPACKABLESTREAM_H -#define SQUID_SRC_TESTS_TESTPACKABLESTREAM_H - -#include "compat/cppunit.h" - -/* - * test PackableStream - */ - -class TestPackableStream: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestPackableStream ); - CPPUNIT_TEST( testGetStream ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - void testGetStream(); -}; - -#endif /* SQUID_SRC_TESTS_TESTPACKABLESTREAM_H */ - diff --git a/src/tests/testRFC1035.cc b/src/tests/testRFC1035.cc index 0caefaeb04..0a23323fcb 100644 --- a/src/tests/testRFC1035.cc +++ b/src/tests/testRFC1035.cc @@ -7,11 +7,35 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "dns/rfc1035.h" -#include "testRFC1035.h" #include "unitTestMain.h" -#include +// #include + +/* + * test the DNS resolver RFC 1035 Engine + */ + +class TestRfc1035 : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestRfc1035); + CPPUNIT_TEST(testHeaderUnpack); + CPPUNIT_TEST(testParseAPacket); + + CPPUNIT_TEST(testBugPacketHeadersOnly); + CPPUNIT_TEST(testBugPacketEndingOnCompressionPtr); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void testHeaderUnpack(); + void testParseAPacket(); + + // bugs. + void testBugPacketEndingOnCompressionPtr(); + void testBugPacketHeadersOnly(); +}; CPPUNIT_TEST_SUITE_REGISTRATION( TestRfc1035 ); diff --git a/src/tests/testRFC1035.h b/src/tests/testRFC1035.h deleted file mode 100644 index f4621bdec0..0000000000 --- a/src/tests/testRFC1035.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_RFC1035_H -#define SQUID_SRC_TEST_RFC1035_H - -#include "compat/cppunit.h" - -/* - * test the DNS resolver RFC 1035 Engine - */ - -class TestRfc1035: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestRfc1035 ); - CPPUNIT_TEST( testHeaderUnpack ); - CPPUNIT_TEST( testParseAPacket ); - - CPPUNIT_TEST( testBugPacketHeadersOnly ); - CPPUNIT_TEST( testBugPacketEndingOnCompressionPtr ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void testHeaderUnpack(); - void testParseAPacket(); - - // bugs. - void testBugPacketEndingOnCompressionPtr(); - void testBugPacketHeadersOnly(); -}; - -#endif /* SQUID_SRC_TEST_IPADDRESS_H */ - diff --git a/src/tests/testRefCount.cc b/src/tests/testRefCount.cc index 08dd2b5206..f463f1aa4f 100644 --- a/src/tests/testRefCount.cc +++ b/src/tests/testRefCount.cc @@ -10,9 +10,33 @@ #include "squid.h" #include "base/RefCount.h" -#include "testRefCount.h" +#include "compat/cppunit.h" #include "unitTestMain.h" +class TestRefCount : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestRefCount); + CPPUNIT_TEST(testCountability); + CPPUNIT_TEST(testObjectToRefCounted); + CPPUNIT_TEST(testStandalonePointer); + CPPUNIT_TEST(testCheckPointers); + CPPUNIT_TEST(testPointerConst); + CPPUNIT_TEST(testRefCountFromConst); + CPPUNIT_TEST(testPointerFromRefCounter); + CPPUNIT_TEST(testDoubleInheritToSingleInherit); + CPPUNIT_TEST_SUITE_END(); + +protected: + void testCountability(); + void testObjectToRefCounted(); + void testStandalonePointer(); + void testCheckPointers(); + void testPointerConst(); + void testRefCountFromConst(); + void testPointerFromRefCounter(); + void testDoubleInheritToSingleInherit(); +}; + CPPUNIT_TEST_SUITE_REGISTRATION( TestRefCount ); class _ToRefCount : public RefCountable diff --git a/src/tests/testRefCount.h b/src/tests/testRefCount.h deleted file mode 100644 index a42a185dd4..0000000000 --- a/src/tests/testRefCount.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_REFCOUNT_H -#define SQUID_SRC_TEST_REFCOUNT_H - -#include "compat/cppunit.h" - -class TestRefCount: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestRefCount ); - CPPUNIT_TEST( testCountability ); - CPPUNIT_TEST( testObjectToRefCounted ); - CPPUNIT_TEST( testStandalonePointer ); - CPPUNIT_TEST( testCheckPointers ); - CPPUNIT_TEST( testPointerConst ); - CPPUNIT_TEST( testRefCountFromConst ); - CPPUNIT_TEST( testPointerFromRefCounter ); - CPPUNIT_TEST( testDoubleInheritToSingleInherit ); - CPPUNIT_TEST_SUITE_END(); - -protected: - void testCountability(); - void testObjectToRefCounted(); - void testStandalonePointer(); - void testCheckPointers(); - void testPointerConst(); - void testRefCountFromConst(); - void testPointerFromRefCounter(); - void testDoubleInheritToSingleInherit(); -}; - -#endif - diff --git a/src/tests/testRock.cc b/src/tests/testRock.cc index 859594f307..69c15875ce 100644 --- a/src/tests/testRock.cc +++ b/src/tests/testRock.cc @@ -7,6 +7,7 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "ConfigParser.h" #include "DiskIO/DiskIOModule.h" #include "fde.h" @@ -22,7 +23,6 @@ #include "store/Disks.h" #include "StoreFileSystem.h" #include "StoreSearch.h" -#include "testRock.h" #include "testStoreSupport.h" #include "unitTestMain.h" @@ -36,7 +36,38 @@ #define TESTDIR "tr" -CPPUNIT_TEST_SUITE_REGISTRATION( TestRock ); +/* + * test the store framework + */ + +class TestRock : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestRock); + CPPUNIT_TEST(testRockCreate); + CPPUNIT_TEST(testRockSwapOut); + CPPUNIT_TEST_SUITE_END(); + +public: + TestRock() : rr(nullptr) {} + void setUp() override; + void tearDown() override; + + typedef RefCount SwapDirPointer; + +protected: + void commonInit(); + void storeInit(); + StoreEntry *createEntry(const int i); + StoreEntry *addEntry(const int i); + StoreEntry *getEntry(const int i); + void testRockCreate(); + void testRockSwapOut(); + +private: + SwapDirPointer store; + Rock::SwapDirRr *rr; +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestRock); extern REMOVALPOLICYCREATE createRemovalPolicy_lru; diff --git a/src/tests/testRock.h b/src/tests/testRock.h deleted file mode 100644 index cf3d322178..0000000000 --- a/src/tests/testRock.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_TESTROCK_H -#define SQUID_SRC_TEST_TESTROCK_H - -#include "compat/cppunit.h" - -/* - * test the store framework - */ - -class TestRock: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestRock ); - CPPUNIT_TEST( testRockCreate ); - CPPUNIT_TEST( testRockSwapOut ); - CPPUNIT_TEST_SUITE_END(); - -public: - TestRock() : rr(nullptr) {} - void setUp() override; - void tearDown() override; - - typedef RefCount SwapDirPointer; - -protected: - void commonInit(); - void storeInit(); - StoreEntry *createEntry(const int i); - StoreEntry *addEntry(const int i); - StoreEntry *getEntry(const int i); - void testRockCreate(); - void testRockSwapOut(); - -private: - SwapDirPointer store; - Rock::SwapDirRr *rr; -}; - -#endif /* SQUID_SRC_TEST_TESTROCK_H */ - diff --git a/src/tests/testSBuf.cc b/src/tests/testSBuf.cc index acfb9bd080..75794ae787 100644 --- a/src/tests/testSBuf.cc +++ b/src/tests/testSBuf.cc @@ -8,23 +8,108 @@ #include "squid.h" #include "base/CharacterSet.h" +#include "base/TextException.h" +#include "compat/cppunit.h" +#include "event.h" #include "HttpReply.h" +#include "MemObject.h" #include "sbuf/Algorithms.h" #include "sbuf/SBuf.h" #include "sbuf/Stream.h" #include "tests/SBufFindTest.h" -#include "tests/testSBuf.h" #include "unitTestMain.h" #include #include #include +/* + * test the SBuf functionalities + */ + +class TestSBuf : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestSBuf); + CPPUNIT_TEST(testSBufConstructDestruct); + CPPUNIT_TEST(testSBufConstructDestructAfterMemInit); + CPPUNIT_TEST(testSBufLength); + CPPUNIT_TEST(testEqualityTest); + CPPUNIT_TEST(testStartsWith); + CPPUNIT_TEST(testAppendSBuf); + CPPUNIT_TEST(testAppendCString); + CPPUNIT_TEST(testAppendStdString); + CPPUNIT_TEST(testAppendf); + CPPUNIT_TEST(testSubscriptOp); + CPPUNIT_TEST_EXCEPTION(testSubscriptOpFail, TextException); + CPPUNIT_TEST(testComparisons); + CPPUNIT_TEST(testConsume); + CPPUNIT_TEST(testRawContent); + CPPUNIT_TEST(testRawSpace); + CPPUNIT_TEST(testChop); + CPPUNIT_TEST(testChomp); + CPPUNIT_TEST(testSubstr); + CPPUNIT_TEST(testFindChar); + CPPUNIT_TEST(testFindSBuf); + CPPUNIT_TEST(testRFindChar); + CPPUNIT_TEST(testRFindSBuf); + CPPUNIT_TEST(testFindFirstOf); + CPPUNIT_TEST(testFindFirstNotOf); + CPPUNIT_TEST(testPrintf); + CPPUNIT_TEST(testCopy); + CPPUNIT_TEST(testStringOps); + CPPUNIT_TEST(testGrow); + CPPUNIT_TEST(testReserve); + CPPUNIT_TEST(testSBufStream); + CPPUNIT_TEST(testAutoFind); + CPPUNIT_TEST(testStdStringOps); + CPPUNIT_TEST(testIterators); + CPPUNIT_TEST(testSBufHash); + // CPPUNIT_TEST( testDumpStats ); //fake test, to print alloc stats + CPPUNIT_TEST_SUITE_END(); + +protected: + void commonInit(); + void testSBufConstructDestruct(); + void testSBufConstructDestructAfterMemInit(); + void testEqualityTest(); + void testAppendSBuf(); + void testAppendCString(); + void testAppendStdString(); + void testAppendf(); + void testPrintf(); + void testSubscriptOp(); + void testSubscriptOpFail(); + void testDumpStats(); + void testComparisons(); + void testConsume(); + void testRawContent(); + void testRawSpace(); + void testChop(); + void testChomp(); + void testSubstr(); + void testTailCopy(); + void testSBufLength(); + void testFindChar(); + void testFindSBuf(); + void testRFindChar(); + void testRFindSBuf(); + void testSearchFail(); + void testCopy(); + void testStringOps(); + void testGrow(); + void testReserve(); + void testStartsWith(); + void testSBufStream(); + void testFindFirstOf(); + void testFindFirstNotOf(); + void testAutoFind(); + void testStdStringOps(); + void testIterators(); + void testSBufHash(); +}; CPPUNIT_TEST_SUITE_REGISTRATION( TestSBuf ); /* let this test link sanely */ -#include "event.h" -#include "MemObject.h" void eventAdd(const char *, EVH *, void *, double, int, bool) {} diff --git a/src/tests/testSBuf.h b/src/tests/testSBuf.h deleted file mode 100644 index 3b66acc7ca..0000000000 --- a/src/tests/testSBuf.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_TESTSBUF_H -#define SQUID_SRC_TEST_TESTSBUF_H - -#include "compat/cppunit.h" - -#include "base/TextException.h" - -/* - * test the SBuf functionalities - */ - -class TestSBuf: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestSBuf ); - CPPUNIT_TEST( testSBufConstructDestruct ); - CPPUNIT_TEST( testSBufConstructDestructAfterMemInit ); - CPPUNIT_TEST( testSBufLength ); - CPPUNIT_TEST( testEqualityTest ); - CPPUNIT_TEST( testStartsWith ); - CPPUNIT_TEST( testAppendSBuf ); - CPPUNIT_TEST( testAppendCString ); - CPPUNIT_TEST( testAppendStdString ); - CPPUNIT_TEST( testAppendf ); - CPPUNIT_TEST( testSubscriptOp ); - CPPUNIT_TEST_EXCEPTION( testSubscriptOpFail, TextException ); - CPPUNIT_TEST( testComparisons ); - CPPUNIT_TEST( testConsume ); - CPPUNIT_TEST( testRawContent ); - CPPUNIT_TEST( testRawSpace ); - CPPUNIT_TEST( testChop ); - CPPUNIT_TEST( testChomp ); - CPPUNIT_TEST( testSubstr ); - CPPUNIT_TEST( testFindChar ); - CPPUNIT_TEST( testFindSBuf ); - CPPUNIT_TEST( testRFindChar ); - CPPUNIT_TEST( testRFindSBuf ); - CPPUNIT_TEST( testFindFirstOf ); - CPPUNIT_TEST( testFindFirstNotOf ); - CPPUNIT_TEST( testPrintf ); - CPPUNIT_TEST( testCopy ); - CPPUNIT_TEST( testStringOps ); - CPPUNIT_TEST( testGrow ); - CPPUNIT_TEST( testReserve ); - CPPUNIT_TEST( testSBufStream ); - CPPUNIT_TEST( testAutoFind ); - CPPUNIT_TEST( testStdStringOps ); - CPPUNIT_TEST( testIterators ); - CPPUNIT_TEST( testSBufHash ); -// CPPUNIT_TEST( testDumpStats ); //fake test, to print alloc stats - CPPUNIT_TEST_SUITE_END(); -protected: - void commonInit(); - void testSBufConstructDestruct(); - void testSBufConstructDestructAfterMemInit(); - void testEqualityTest(); - void testAppendSBuf(); - void testAppendCString(); - void testAppendStdString(); - void testAppendf(); - void testPrintf(); - void testSubscriptOp(); - void testSubscriptOpFail(); - void testDumpStats(); - void testComparisons(); - void testConsume(); - void testRawContent(); - void testRawSpace(); - void testChop(); - void testChomp(); - void testSubstr(); - void testTailCopy(); - void testSBufLength(); - void testFindChar(); - void testFindSBuf(); - void testRFindChar(); - void testRFindSBuf(); - void testSearchFail(); - void testCopy(); - void testStringOps(); - void testGrow(); - void testReserve(); - void testStartsWith(); - void testSBufStream(); - void testFindFirstOf(); - void testFindFirstNotOf(); - void testAutoFind(); - void testStdStringOps(); - void testIterators(); - void testSBufHash(); -}; - -#endif - diff --git a/src/tests/testSBufList.cc b/src/tests/testSBufList.cc index ec05c5b970..dc9f38ac68 100644 --- a/src/tests/testSBufList.cc +++ b/src/tests/testSBufList.cc @@ -7,11 +7,22 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "sbuf/Algorithms.h" #include "sbuf/List.h" -#include "tests/testSBufList.h" #include "unitTestMain.h" +class TestSBufList : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestSBufList); + CPPUNIT_TEST(testSBufListMembership); + CPPUNIT_TEST(testSBufListJoin); + CPPUNIT_TEST_SUITE_END(); + +protected: + void testSBufListMembership(); + void testSBufListJoin(); +}; CPPUNIT_TEST_SUITE_REGISTRATION( TestSBufList ); SBuf literal("The quick brown fox jumped over the lazy dog"); diff --git a/src/tests/testSBufList.h b/src/tests/testSBufList.h deleted file mode 100644 index a22e39e257..0000000000 --- a/src/tests/testSBufList.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_TESTSBUF_H -#define SQUID_SRC_TEST_TESTSBUF_H - -#include "compat/cppunit.h" - -class TestSBufList: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestSBufList ); - CPPUNIT_TEST( testSBufListMembership ); - CPPUNIT_TEST( testSBufListJoin ); - CPPUNIT_TEST_SUITE_END(); -protected: - void testSBufListMembership(); - void testSBufListJoin(); -}; - -#endif - diff --git a/src/tests/testStatHist.cc b/src/tests/testStatHist.cc index 5e71c55e77..0ba18753ff 100644 --- a/src/tests/testStatHist.cc +++ b/src/tests/testStatHist.cc @@ -7,10 +7,26 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "StatHist.h" -#include "testStatHist.h" #include "unitTestMain.h" +class TestStatHist : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestStatHist); + CPPUNIT_TEST(testStatHistBaseEquality); + CPPUNIT_TEST(testStatHistBaseAssignment); + CPPUNIT_TEST(testStatHistLog); + CPPUNIT_TEST(testStatHistSum); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void testStatHistBaseEquality(); + void testStatHistBaseAssignment(); + void testStatHistLog(); + void testStatHistSum(); +}; CPPUNIT_TEST_SUITE_REGISTRATION( TestStatHist ); typedef enum { diff --git a/src/tests/testStatHist.h b/src/tests/testStatHist.h deleted file mode 100644 index c498579184..0000000000 --- a/src/tests/testStatHist.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -/* - * StatHist unit test - */ - -#ifndef TESTSTATHIST_H_ -#define TESTSTATHIST_H_ - -#include "compat/cppunit.h" - -class TestStatHist: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestStatHist ); - CPPUNIT_TEST( testStatHistBaseEquality ); - CPPUNIT_TEST( testStatHistBaseAssignment ); - CPPUNIT_TEST( testStatHistLog ); - CPPUNIT_TEST( testStatHistSum ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void testStatHistBaseEquality(); - void testStatHistBaseAssignment(); - void testStatHistLog(); - void testStatHistSum(); -}; - -#endif /* TESTSTATHIST_H_ */ - diff --git a/src/tests/testStoreController.cc b/src/tests/testStoreController.cc index ff528f135f..39596b948d 100644 --- a/src/tests/testStoreController.cc +++ b/src/tests/testStoreController.cc @@ -7,15 +7,33 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "MemObject.h" #include "SquidConfig.h" #include "Store.h" #include "store/Disks.h" #include "StoreSearch.h" -#include "testStoreController.h" #include "TestSwapDir.h" -CPPUNIT_TEST_SUITE_REGISTRATION( TestStoreController ); +/* + * test the store framework + */ + +class TestStoreController : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestStoreController); + CPPUNIT_TEST(testStats); + CPPUNIT_TEST(testMaxSize); + CPPUNIT_TEST(testSearch); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void testStats(); + void testMaxSize(); + void testSearch(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestStoreController); static void addSwapDir(TestSwapDirPointer aStore) diff --git a/src/tests/testStoreController.h b/src/tests/testStoreController.h deleted file mode 100644 index 5a5bcde35e..0000000000 --- a/src/tests/testStoreController.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_STORECONTROLLER_H -#define SQUID_SRC_TEST_STORECONTROLLER_H - -#include "compat/cppunit.h" - -/* - * test the store framework - */ - -class TestStoreController: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestStoreController ); - CPPUNIT_TEST( testStats ); - CPPUNIT_TEST( testMaxSize ); - CPPUNIT_TEST( testSearch ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void testStats(); - void testMaxSize(); - void testSearch(); -}; - -#endif - diff --git a/src/tests/testStoreHashIndex.cc b/src/tests/testStoreHashIndex.cc index 7ddf48f667..2349d4c86e 100644 --- a/src/tests/testStoreHashIndex.cc +++ b/src/tests/testStoreHashIndex.cc @@ -7,15 +7,33 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "MemObject.h" #include "SquidConfig.h" #include "Store.h" #include "store/Disks.h" #include "StoreSearch.h" -#include "testStoreHashIndex.h" #include "TestSwapDir.h" -CPPUNIT_TEST_SUITE_REGISTRATION( TestStoreHashIndex ); +/* + * test the store framework + */ + +class TestStoreHashIndex : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestStoreHashIndex); + CPPUNIT_TEST(testStats); + CPPUNIT_TEST(testMaxSize); + CPPUNIT_TEST(testSearch); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void testStats(); + void testMaxSize(); + void testSearch(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestStoreHashIndex); static void addSwapDir(TestSwapDirPointer aStore) diff --git a/src/tests/testStoreHashIndex.h b/src/tests/testStoreHashIndex.h deleted file mode 100644 index 0e70fc3357..0000000000 --- a/src/tests/testStoreHashIndex.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_STOREHASHINDEX_H -#define SQUID_SRC_TEST_STOREHASHINDEX_H - -#include "compat/cppunit.h" - -/* - * test the store framework - */ - -class TestStoreHashIndex: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestStoreHashIndex ); - CPPUNIT_TEST( testStats ); - CPPUNIT_TEST( testMaxSize ); - CPPUNIT_TEST( testSearch ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void testStats(); - void testMaxSize(); - void testSearch(); -}; - -#endif - diff --git a/src/tests/testString.cc b/src/tests/testString.cc index 2af7b74eda..fad4dfff72 100644 --- a/src/tests/testString.cc +++ b/src/tests/testString.cc @@ -7,12 +7,35 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "mem/forward.h" #include "SquidString.h" -#include "testString.h" #include "unitTestMain.h" -CPPUNIT_TEST_SUITE_REGISTRATION( TestString ); +/* + * test the store framework + */ + +class TestString : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestString); + CPPUNIT_TEST(testCmpDefault); + CPPUNIT_TEST(testCmpEmptyString); + CPPUNIT_TEST(testCmpNotEmptyDefault); + CPPUNIT_TEST(testSubstr); + + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + void testCmpDefault(); + void testCmpEmptyString(); + void testCmpNotEmptyDefault(); + void testSubstr(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestString); /* init memory pools */ diff --git a/src/tests/testString.h b/src/tests/testString.h deleted file mode 100644 index 2d176276fe..0000000000 --- a/src/tests/testString.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_STRING_H -#define SQUID_SRC_TEST_STRING_H - -#include "compat/cppunit.h" - -/* - * test the store framework - */ - -class TestString: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestString ); - CPPUNIT_TEST( testCmpDefault ); - CPPUNIT_TEST( testCmpEmptyString ); - CPPUNIT_TEST( testCmpNotEmptyDefault ); - CPPUNIT_TEST( testSubstr ); - - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - void testCmpDefault(); - void testCmpEmptyString(); - void testCmpNotEmptyDefault(); - void testSubstr(); -}; - -#endif - diff --git a/src/tests/testTokenizer.cc b/src/tests/testTokenizer.cc index dcf0709bcb..27b64591b2 100644 --- a/src/tests/testTokenizer.cc +++ b/src/tests/testTokenizer.cc @@ -8,11 +8,30 @@ #include "squid.h" #include "base/CharacterSet.h" +#include "compat/cppunit.h" #include "parser/Tokenizer.h" -#include "tests/testTokenizer.h" #include "unitTestMain.h" -CPPUNIT_TEST_SUITE_REGISTRATION( TestTokenizer ); +class TestTokenizer : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestTokenizer); + CPPUNIT_TEST(testCharacterSet); + CPPUNIT_TEST(testTokenizerPrefix); + CPPUNIT_TEST(testTokenizerSuffix); + CPPUNIT_TEST(testTokenizerSkip); + CPPUNIT_TEST(testTokenizerToken); + CPPUNIT_TEST(testTokenizerInt64); + CPPUNIT_TEST_SUITE_END(); + +protected: + void testTokenizerPrefix(); + void testTokenizerSuffix(); + void testTokenizerSkip(); + void testTokenizerToken(); + void testCharacterSet(); + void testTokenizerInt64(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestTokenizer); SBuf text("GET http://resource.com/path HTTP/1.1\r\n" "Host: resource.com\r\n" diff --git a/src/tests/testTokenizer.h b/src/tests/testTokenizer.h deleted file mode 100644 index c0d519ae5e..0000000000 --- a/src/tests/testTokenizer.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_TESTTOKENIZER_H_ -#define SQUID_TESTTOKENIZER_H_ - -#include "compat/cppunit.h" - -class TestTokenizer: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestTokenizer ); - CPPUNIT_TEST ( testCharacterSet ); - CPPUNIT_TEST ( testTokenizerPrefix ); - CPPUNIT_TEST ( testTokenizerSuffix ); - CPPUNIT_TEST ( testTokenizerSkip ); - CPPUNIT_TEST ( testTokenizerToken ); - CPPUNIT_TEST ( testTokenizerInt64 ); - CPPUNIT_TEST_SUITE_END(); - -protected: - void testTokenizerPrefix(); - void testTokenizerSuffix(); - void testTokenizerSkip(); - void testTokenizerToken(); - void testCharacterSet(); - void testTokenizerInt64(); -}; - -#endif /* SQUID_TESTTOKENIZER_H_ */ - diff --git a/src/tests/testURL.cc b/src/tests/testURL.cc index c18618d8b8..6b5b57f183 100644 --- a/src/tests/testURL.cc +++ b/src/tests/testURL.cc @@ -8,16 +8,33 @@ #include "squid.h" -#include - #include "anyp/Uri.h" +#include "compat/cppunit.h" #include "debug/Stream.h" -#include "tests/testURL.h" #include "unitTestMain.h" +#include #include -CPPUNIT_TEST_SUITE_REGISTRATION( TestUri ); +/* + * test the Anyp::Uri-related classes + */ + +class TestUri : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestUri); + CPPUNIT_TEST(testConstructScheme); + CPPUNIT_TEST(testDefaultConstructor); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + void testConstructScheme(); + void testDefaultConstructor(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestUri); /* init memory pools */ diff --git a/src/tests/testURL.h b/src/tests/testURL.h deleted file mode 100644 index dc097ab6a9..0000000000 --- a/src/tests/testURL.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_URL_H -#define SQUID_SRC_TEST_URL_H - -#include "compat/cppunit.h" - -/* - * test the Anyp::Uri-related classes - */ - -class TestUri: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestUri ); - CPPUNIT_TEST( testConstructScheme ); - CPPUNIT_TEST( testDefaultConstructor ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - - void testConstructScheme(); - void testDefaultConstructor(); -}; - -#endif - diff --git a/src/tests/testUfs.cc b/src/tests/testUfs.cc index e094aef0f0..659d224c57 100644 --- a/src/tests/testUfs.cc +++ b/src/tests/testUfs.cc @@ -7,6 +7,7 @@ */ #include "squid.h" +#include "compat/cppunit.h" #include "DiskIO/DiskIOModule.h" #include "fde.h" #include "fs/ufs/UFSSwapDir.h" @@ -19,14 +20,30 @@ #include "Store.h" #include "store/Disks.h" #include "testStoreSupport.h" -#include "testUfs.h" #include "unitTestMain.h" #include #define TESTDIR "TestUfs_Store" -CPPUNIT_TEST_SUITE_REGISTRATION( TestUfs ); +/* + * test the store framework + */ + +class TestUfs : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestUfs); + CPPUNIT_TEST(testUfsSearch); + CPPUNIT_TEST(testUfsDefaultEngine); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void commonInit(); + void testUfsSearch(); + void testUfsDefaultEngine(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestUfs); typedef RefCount MySwapDirPointer; extern REMOVALPOLICYCREATE createRemovalPolicy_lru; /* XXX fails with --enable-removal-policies=heap */ diff --git a/src/tests/testUfs.h b/src/tests/testUfs.h deleted file mode 100644 index 07c244f7c8..0000000000 --- a/src/tests/testUfs.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TEST_STORECONTROLLER_H -#define SQUID_SRC_TEST_STORECONTROLLER_H - -#include "compat/cppunit.h" - -/* - * test the store framework - */ - -class TestUfs: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestUfs ); - CPPUNIT_TEST( testUfsSearch ); - CPPUNIT_TEST( testUfsDefaultEngine ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void commonInit(); - void testUfsSearch(); - void testUfsDefaultEngine(); -}; - -#endif - diff --git a/src/tests/testUriScheme.cc b/src/tests/testUriScheme.cc index 960c054dc7..0b2f54d825 100644 --- a/src/tests/testUriScheme.cc +++ b/src/tests/testUriScheme.cc @@ -8,14 +8,43 @@ #include "squid.h" -#include - #include "anyp/UriScheme.h" -#include "tests/testUriScheme.h" +#include "compat/cppunit.h" +#include #include -CPPUNIT_TEST_SUITE_REGISTRATION( TestUriScheme ); +/* + * test UriScheme + */ + +class TestUriScheme : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestUriScheme); + CPPUNIT_TEST(testAssignFromprotocol_t); + CPPUNIT_TEST(testCastToprotocol_t); + CPPUNIT_TEST(testConstructprotocol_t); + CPPUNIT_TEST(testDefaultConstructor); + CPPUNIT_TEST(testEqualprotocol_t); + CPPUNIT_TEST(testNotEqualprotocol_t); + CPPUNIT_TEST(testC_str); + CPPUNIT_TEST(testStream); + CPPUNIT_TEST_SUITE_END(); + +public: + void setUp() override; + +protected: + void testAssignFromprotocol_t(); + void testCastToprotocol_t(); + void testConstructprotocol_t(); + void testC_str(); + void testDefaultConstructor(); + void testEqualprotocol_t(); + void testNotEqualprotocol_t(); + void testStream(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestUriScheme); /* * we should be able to assign a protocol_t to a AnyP::UriScheme for ease diff --git a/src/tests/testUriScheme.h b/src/tests/testUriScheme.h deleted file mode 100644 index 0b9157cd72..0000000000 --- a/src/tests/testUriScheme.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TESTS_TESTURISCHEME_H -#define SQUID_SRC_TESTS_TESTURISCHEME_H - -#include "compat/cppunit.h" - -/* - * test UriScheme - */ - -class TestUriScheme: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestUriScheme ); - CPPUNIT_TEST( testAssignFromprotocol_t ); - CPPUNIT_TEST( testCastToprotocol_t ); - CPPUNIT_TEST( testConstructprotocol_t ); - CPPUNIT_TEST( testDefaultConstructor ); - CPPUNIT_TEST( testEqualprotocol_t ); - CPPUNIT_TEST( testNotEqualprotocol_t ); - CPPUNIT_TEST( testC_str ); - CPPUNIT_TEST( testStream ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp() override; - -protected: - void testAssignFromprotocol_t(); - void testCastToprotocol_t(); - void testConstructprotocol_t(); - void testC_str(); - void testDefaultConstructor(); - void testEqualprotocol_t(); - void testNotEqualprotocol_t(); - void testStream(); -}; - -#endif - diff --git a/src/tests/testYesNoNone.cc b/src/tests/testYesNoNone.cc index 0a7233551c..1f7b05880a 100644 --- a/src/tests/testYesNoNone.cc +++ b/src/tests/testYesNoNone.cc @@ -8,12 +8,28 @@ #include "squid.h" #include "base/YesNoNone.h" -#include "tests/testYesNoNone.h" +#include "compat/cppunit.h" #include "unitTestMain.h" #include -CPPUNIT_TEST_SUITE_REGISTRATION( TestYesNoNone ); +/* + * demonstration test file, as new idioms are made they will + * be shown in the TestYesNoNone source. + */ + +class TestYesNoNone : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE(TestYesNoNone); + /* note the statement here and then the actual prototype below */ + CPPUNIT_TEST(testBasics); + CPPUNIT_TEST_SUITE_END(); + +public: +protected: + void testBasics(); +}; +CPPUNIT_TEST_SUITE_REGISTRATION(TestYesNoNone); void TestYesNoNone::testBasics() diff --git a/src/tests/testYesNoNone.h b/src/tests/testYesNoNone.h deleted file mode 100644 index 8b79757021..0000000000 --- a/src/tests/testYesNoNone.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 1996-2023 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_SRC_TESTS_TESTYESNONONE_H -#define SQUID_SRC_TESTS_TESTYESNONONE_H - -#include "compat/cppunit.h" - -/* - * demonstration test file, as new idioms are made they will - * be shown in the TestYesNoNone source. - */ - -class TestYesNoNone: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TestYesNoNone ); - /* note the statement here and then the actual prototype below */ - CPPUNIT_TEST( testBasics ); - CPPUNIT_TEST_SUITE_END(); - -public: - -protected: - void testBasics(); -}; - -#endif /* SQUID_SRC_TESTS_TESTYESNONONE_H */ - -- 2.47.3