1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
/* ====================================================================
* Copyright (c) 2007, Martin Hauner
* http://subcommander.tigris.org
*
* Subcommander is licensed as described in the file doc/COPYING, which
* you should have received as part of this distribution.
* ====================================================================
*/
// test
#include "CompareTest.h"
// cppunit
#include <cppunit/TestSuite.h>
#include <cppunit/TestCaller.h>
// sc
#include "util/Compare.h"
#include "util/String.h"
/*
test compare method for dir first sorting. This is tricky for flat display.
sc
sc/doc
sc/doc/doxygen
sc/doc/doxygen/doxgen.conf
sc/doc/file
sc/subcommander
sc/subcommander/commands/Cmd.h
sc/subcommander/WcStatusLvi.h
sc/doxgen.conf
sc/sc.ini
*/
void CompareTest::setUp()
{
}
void CompareTest::tearDown()
{
}
void CompareTest::testDirDir()
{
CPPUNIT_ASSERT_EQUAL( 0,
compare3( sc::String("sc/doc"), true, sc::String("sc/doc"), true ) );
CPPUNIT_ASSERT_EQUAL( -1,
compare3( sc::String("sc/doc"), true, sc::String("sc/doc/doxygen"), true ) );
CPPUNIT_ASSERT_EQUAL( 1,
compare3( sc::String("sc/subcommander"), true, sc::String("sc/doc/doxygen"), true ) );
}
void CompareTest::testDirFile()
{
CPPUNIT_ASSERT_EQUAL( -1,
compare3( sc::String("sc/doc"), true, sc::String("sc/conf.txt"), false ) );
CPPUNIT_ASSERT_EQUAL( -1,
compare3( sc::String("sc/doc"), true, sc::String("sc/doxgen.conf"), false ) );
CPPUNIT_ASSERT_EQUAL( 1,
compare3( sc::String("sc/pics"), true, sc::String("sc/doc/doxygen/doxgen.conf"), false ) );
CPPUNIT_ASSERT_EQUAL( -1,
compare3( sc::String("sc/subcommander"), true, sc::String("sc/sc.ini"), false ) );
CPPUNIT_ASSERT_EQUAL( -1,
compare3( sc::String("sc/subcommander/commands"), true, sc::String("sc/sc.ini"), false ) );
CPPUNIT_ASSERT_EQUAL( -1,
compare3( sc::String("sc/subcommander"), true, sc::String("sc/subcommander/BookmarkLvi.h"), false ) );
}
void CompareTest::testFileDir()
{
CPPUNIT_ASSERT_EQUAL( 1,
compare3( sc::String("sc/conf.txt"), false, sc::String("sc/doc"), true ) );
CPPUNIT_ASSERT_EQUAL( 1,
compare3( sc::String("sc/doxgen.conf"), false, sc::String("sc/doc"), true ) );
CPPUNIT_ASSERT_EQUAL( -1,
compare3( sc::String("sc/doc/doxygen/doxgen.conf"), false, sc::String("sc/pics"), true ) );
CPPUNIT_ASSERT_EQUAL( 1,
compare3( sc::String("sc/sc.ini"), false, sc::String("sc/subcommander"), true ) );
CPPUNIT_ASSERT_EQUAL( 1,
compare3( sc::String("sc/sc.ini"), false, sc::String("sc/subcommander/commands"), true ) );
CPPUNIT_ASSERT_EQUAL( 1,
compare3( sc::String("sc/subcommander/BookmarkLvi.h"), false, sc::String("sc/subcommander"), true ) );
}
void CompareTest::testFileFile()
{
CPPUNIT_ASSERT_EQUAL( 0,
compare3( sc::String("sc.ini"), false, sc::String("sc.ini"), false ) );
CPPUNIT_ASSERT_EQUAL( 1,
compare3( sc::String("sc/util/uuid.h"), false, sc::String("sc/util/uuid.cpp"), false ) );
CPPUNIT_ASSERT_EQUAL( -1,
compare3( sc::String("sc/util/uuid.cpp"), false, sc::String("sc/util/uuid.h"), false ) );
CPPUNIT_ASSERT_EQUAL( -1,
compare3( sc::String("sc/pics/image.png"), false, sc::String("sc/sc.ini"), false ) );
CPPUNIT_ASSERT_EQUAL( 1,
compare3( sc::String("sc/sc.ini"), false, sc::String("sc/pics/image.png"), false ) );
CPPUNIT_ASSERT_EQUAL( 1,
compare3( sc::String("sc/c/d/c/d/image.png"), false, sc::String("sc/b/c/sc.ini"), false ) );
CPPUNIT_ASSERT_EQUAL( -1,
compare3( sc::String("sc/b/c/sc.ini"), false, sc::String("sc/c/d/c/d/image.png"), false ) );
}
|