test: use GTest instead of cppunit
This commit is contained in:
@@ -2,76 +2,46 @@
|
||||
#include "archive/ArchiveLookup.hxx"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
#include <cppunit/TestFixture.h>
|
||||
#include <cppunit/extensions/TestFactoryRegistry.h>
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
class ArchiveLookupTest : public CppUnit::TestFixture {
|
||||
CPPUNIT_TEST_SUITE(ArchiveLookupTest);
|
||||
CPPUNIT_TEST(TestArchiveLookup);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
void TestArchiveLookup();
|
||||
};
|
||||
|
||||
void
|
||||
ArchiveLookupTest::TestArchiveLookup()
|
||||
TEST(ArchiveTest, Lookup)
|
||||
{
|
||||
const char *archive, *inpath, *suffix;
|
||||
|
||||
char *path = strdup("");
|
||||
CPPUNIT_ASSERT_EQUAL(false,
|
||||
archive_lookup(path, &archive, &inpath, &suffix));
|
||||
EXPECT_FALSE(archive_lookup(path, &archive, &inpath, &suffix));
|
||||
free(path);
|
||||
|
||||
path = strdup(".");
|
||||
CPPUNIT_ASSERT_EQUAL(false,
|
||||
archive_lookup(path, &archive, &inpath, &suffix));
|
||||
EXPECT_FALSE(archive_lookup(path, &archive, &inpath, &suffix));
|
||||
free(path);
|
||||
|
||||
path = strdup("config.h");
|
||||
CPPUNIT_ASSERT_EQUAL(false,
|
||||
archive_lookup(path, &archive, &inpath, &suffix));
|
||||
EXPECT_FALSE(archive_lookup(path, &archive, &inpath, &suffix));
|
||||
free(path);
|
||||
|
||||
path = strdup("src/foo/bar");
|
||||
CPPUNIT_ASSERT_EQUAL(false,
|
||||
archive_lookup(path, &archive, &inpath, &suffix));
|
||||
EXPECT_FALSE(archive_lookup(path, &archive, &inpath, &suffix));
|
||||
free(path);
|
||||
|
||||
fclose(fopen("dummy", "w"));
|
||||
|
||||
path = strdup("dummy/foo/bar");
|
||||
CPPUNIT_ASSERT_EQUAL(true,
|
||||
archive_lookup(path, &archive, &inpath, &suffix));
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)path, archive);
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(archive, "dummy"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(inpath, "foo/bar"));
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)nullptr, suffix);
|
||||
EXPECT_TRUE(archive_lookup(path, &archive, &inpath, &suffix));
|
||||
EXPECT_EQ((const char *)path, archive);
|
||||
EXPECT_STREQ(archive, "dummy");
|
||||
EXPECT_STREQ(inpath, "foo/bar");
|
||||
EXPECT_EQ((const char *)nullptr, suffix);
|
||||
free(path);
|
||||
|
||||
path = strdup("config.h/foo/bar");
|
||||
CPPUNIT_ASSERT_EQUAL(true,
|
||||
archive_lookup(path, &archive, &inpath, &suffix));
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)path, archive);
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(archive, "config.h"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(inpath, "foo/bar"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(suffix, "h"));
|
||||
EXPECT_TRUE(archive_lookup(path, &archive, &inpath, &suffix));
|
||||
EXPECT_EQ((const char *)path, archive);
|
||||
EXPECT_STREQ(archive, "config.h");
|
||||
EXPECT_STREQ(inpath, "foo/bar");
|
||||
EXPECT_STREQ(suffix, "h");
|
||||
free(path);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(ArchiveLookupTest);
|
||||
|
||||
int
|
||||
main(gcc_unused int argc, gcc_unused char **argv)
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
auto ®istry = CppUnit::TestFactoryRegistry::getRegistry();
|
||||
runner.addTest(registry.makeTest());
|
||||
return runner.run() ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user