add test for translated text
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 20 Jun 2006 11:13:04 +0000 (11:13 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 20 Jun 2006 11:13:04 +0000 (11:13 +0000)
testsuite/zypp/tests/Makefile.am
testsuite/zypp/tests/TranslatedText.cc [new file with mode: 0644]
testsuite/zypp/zypp.test/TranslatedText.exp [new file with mode: 0644]

index 6259ecf..65295b9 100644 (file)
@@ -11,7 +11,8 @@ noinst_PROGRAMS = Arch Url1 Url2 Url3 Url4 Url5 Url \
        RWPtr \
        Edition         \
        Capabilities    \
-       PtrTypes
+       PtrTypes \
+       TranslatedText
 
 ## ##################################################
 
@@ -26,6 +27,7 @@ Url3_SOURCES = Url3.cc
 Url4_SOURCES = Url4.cc
 Url5_SOURCES = Url5.cc
 Url_SOURCES  = Url.cc
+TranslatedText_SOURCES  = TranslatedText.cc
 RWPtr_SOURCES = RWPtr.cc
 Edition_SOURCES = Edition.cc
 Capabilities_SOURCES = Capabilities.cc
diff --git a/testsuite/zypp/tests/TranslatedText.cc b/testsuite/zypp/tests/TranslatedText.cc
new file mode 100644 (file)
index 0000000..2cced62
--- /dev/null
@@ -0,0 +1,69 @@
+// Arch.cc
+//
+// tests for Arch
+//
+
+#include <iostream>
+#include <list>
+#include <string>
+
+#include "zypp/base/Logger.h"
+#include "zypp/TranslatedText.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/ZYpp.h"
+
+using namespace std;
+using namespace zypp;
+
+int main( int argc, char * argv[] )
+{
+  ZYpp::Ptr god;
+  
+  try { 
+    god = getZYpp();
+  }
+  catch( const Exception &e )
+  {
+    return 99;
+  }
+  
+  TranslatedText testTT;
+  MIL << "Locale: en" << std::endl;
+  god->setTextLocale(Locale("en"));
+  testTT.setText("default");
+  if ( testTT.text() != "default" )
+    return 2;
+  
+  testTT.setText("default english", Locale("en"));
+  if ( testTT.text() != "default english" )
+    return 3;
+  
+  MIL << "Locale: es_ES" << std::endl;
+  god->setTextLocale(Locale("es_ES"));
+  
+  if ( testTT.text() != "default english" )
+  {
+    ERR << testTT.text() << std::endl;
+    return 4;
+  }
+    
+  testTT.setText("hola esto es neutro", Locale("es"));
+  testTT.setText("this is neutral", Locale("en"));
+  
+  if ( testTT.text() != "hola esto es neutro" )
+    return 5;
+    
+  testTT.setText("hola Spain", Locale("es_ES"));
+  if ( testTT.text() != "hola Spain" )
+    return 6;
+  
+  MIL << "Locale: null" << std::endl;
+  god->setTextLocale(Locale());
+  if ( testTT.text() != "default" )
+  {
+    ERR << testTT.text() << std::endl;
+    return 7;
+  }
+  
+  return 0;
+}
diff --git a/testsuite/zypp/zypp.test/TranslatedText.exp b/testsuite/zypp/zypp.test/TranslatedText.exp
new file mode 100644 (file)
index 0000000..03750e1
--- /dev/null
@@ -0,0 +1,4 @@
+# TranslatedText.exp
+# run tests for TranslatedText
+
+  shouldPass "TranslatedText"