Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: source/test/intltest/datadrivennumberformattestsuite.h

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/test/intltest/csdetest.cpp ('k') | source/test/intltest/datadrivennumberformattestsuite.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/test/intltest/datadrivennumberformattestsuite.h
diff --git a/source/test/intltest/datadrivennumberformattestsuite.h b/source/test/intltest/datadrivennumberformattestsuite.h
new file mode 100644
index 0000000000000000000000000000000000000000..9af62376fd6d219ba3a5f893b6323a39a21e6c38
--- /dev/null
+++ b/source/test/intltest/datadrivennumberformattestsuite.h
@@ -0,0 +1,141 @@
+/************************************************************************
+ * COPYRIGHT:
+ * Copyright (c) 2015, International Business Machines Corporation
+ * and others. All Rights Reserved.
+ ************************************************************************/
+
+#ifndef _DATADRIVENNUMBERFORMATTESTSUITE_H__
+#define _DATADRIVENNUMBERFORMATTESTSUITE_H__
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uobject.h"
+#include "unicode/unistr.h"
+#include "numberformattesttuple.h"
+#include "intltest.h"
+
+struct UCHARBUF;
+class IntlTest;
+
+/**
+ * Performs various in-depth test on NumberFormat
+ **/
+class DataDrivenNumberFormatTestSuite : public IntlTest {
+
+ public:
+ DataDrivenNumberFormatTestSuite() {
+ for (int32_t i = 0; i < UPRV_LENGTHOF(fPreviousFormatters); ++i) {
+ fPreviousFormatters[i] = NULL;
+ }
+ }
+
+ /**
+ * Runs the data driven test suite.
+ *
+ * @param fileName is the name of the file in the source/test/testdata.
+ * This should be just a filename such as "numberformattest.txt"
+ * @param runAllTests If TRUE, runs every test in fileName. if FALSE,
+ * skips the tests that are known to break for ICU4C.
+ */
+ void run(const char *fileName, UBool runAllTests);
+ virtual ~DataDrivenNumberFormatTestSuite();
+ protected:
+ /**
+ * Subclasses override this method to test formatting numbers.
+ * Subclasses must not override both isFormatPass methods.
+ * @param tuple the test data for current test. The format method can
+ * assume that the format and output fields are populated.
+ * @param appendErrorMessage any message describing failures appended
+ * here.
+ * @param status any error returned here.
+ * @return TRUE if test passed or FALSE if test failed.
+ */
+ virtual UBool isFormatPass(
+ const NumberFormatTestTuple &tuple,
+ UnicodeString &appendErrorMessage,
+ UErrorCode &status);
+
+
+ /**
+ * Subclasses override this method to test formatting numbers.
+ * Along with copy and assignment operators.
+ * @param tuple the test data for current test. The format method can
+ * assume that the format and output fields are populated.
+ * @param somePreviousFormatter A pointer to a previous formatter
+ * that the test framework owns. This formatter changes as tests
+ * are run. Subclasses should initialize a formatter and assign
+ * the newly initialized formatter to this formatter. In this way,
+ * assignment gets tested with multiple previous states.
+ * @param appendErrorMessage any message describing failures appended
+ * here.
+ * @param status any error returned here.
+ * @return TRUE if test passed or FALSE if test failed.
+ */
+ virtual UBool isFormatPass(
+ const NumberFormatTestTuple &tuple,
+ UObject *somePreviousFormatter,
+ UnicodeString &appendErrorMessage,
+ UErrorCode &status);
+ /**
+ * If subclass is testing formatting with copy and assignmet, it
+ * needs to override this method to return a newly allocated formatter.
+ */
+ virtual UObject *newFormatter(UErrorCode &status);
+
+ /**
+ * Tests toPattern method.
+ */
+ virtual UBool isToPatternPass(
+ const NumberFormatTestTuple &tuple,
+ UnicodeString &appendErrorMessage,
+ UErrorCode &status);
+ /**
+ * Test parsing.
+ */
+ virtual UBool isParsePass(
+ const NumberFormatTestTuple &tuple,
+ UnicodeString &appendErrorMessage,
+ UErrorCode &status);
+
+ /**
+ * Test parsing with currency.
+ */
+ virtual UBool isParseCurrencyPass(
+ const NumberFormatTestTuple &tuple,
+ UnicodeString &appendErrorMessage,
+ UErrorCode &status);
+
+ /**
+ * Test plural selection.
+ */
+ virtual UBool isSelectPass(
+ const NumberFormatTestTuple &tuple,
+ UnicodeString &appendErrorMessage,
+ UErrorCode &status);
+ private:
+ UnicodeString fFileLine;
+ int32_t fFileLineNumber;
+ UnicodeString fFileTestName;
+ NumberFormatTestTuple fTuple;
+ int32_t fFormatTestNumber;
+ UObject *fPreviousFormatters[13];
+
+ void setTupleField(UErrorCode &);
+ int32_t splitBy(
+ UnicodeString *columnValues,
+ int32_t columnValueCount,
+ UChar delimiter);
+ void showError(const char *message);
+ void showFailure(const UnicodeString &message);
+ void showLineInfo();
+ UBool breaksC();
+ UBool readLine(UCHARBUF *f, UErrorCode &);
+ UBool isPass(
+ const NumberFormatTestTuple &tuple,
+ UnicodeString &appendErrorMessage,
+ UErrorCode &status);
+};
+#endif /* !UCONFIG_NO_FORMATTING */
+#endif // _DATADRIVENNUMBERFORMATTESTSUITE_
« no previous file with comments | « source/test/intltest/csdetest.cpp ('k') | source/test/intltest/datadrivennumberformattestsuite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698