• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

test/TestStringTable.cpp

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #include <spl/Debug.h>
00018 
00019 #if defined(DEBUG) || defined(_DEBUG)
00020 
00021 #include <spl/Log.h>
00022 #include <spl/collection/StringTable.h>
00023 
00024 static void _TestStringTableNull()
00025 {
00026         StringTable st;
00027         
00028         DEBUG_CLEAR_MEM_CHECK_POINTS();
00029         st.CheckMem();
00030         UNIT_ASSERT_MEM_NOTED("StringTable 1.0");
00031 
00032         Log::SWriteOkFail( "StringTable test null" );
00033 }
00034 
00035 static void _TestStringTable1()
00036 {
00037         StringTable st;
00038         
00039         String *sp = st.GetPtr("bob");
00040         UNIT_ASSERT("bob", sp->Equals("bob"));
00041         UNIT_ASSERT_MEM("string", sp, sizeof(String));
00042 
00043         String& sr = st.Get("bob");
00044         UNIT_ASSERT("bob", sr.Equals("bob"));
00045 
00046         sr = "hi";
00047         UNIT_ASSERT("hi", sp->Equals("hi"));
00048 
00049         DEBUG_CLEAR_MEM_CHECK_POINTS();
00050         st.CheckMem();
00051         UNIT_ASSERT_MEM_NOTED("StringTable 1.0");
00052 
00053         Log::SWriteOkFail( "StringTable test 1" );
00054 }
00055 
00056 void _TestStringTable(  )
00057 {
00058         _TestStringTableNull();
00059         DEBUG_CLEAR_MEM_CHECK_POINTS();
00060         UNIT_ASSERT_MEM_NOTED("StringTable A");
00061 
00062         _TestStringTable1();
00063         DEBUG_CLEAR_MEM_CHECK_POINTS();
00064         UNIT_ASSERT_MEM_NOTED("StringTable B");
00065 }
00066 
00067 #endif