You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2006/10/24 21:49:46 UTC

svn commit: r467454 - in /lucene/lucy/trunk/charmonizer: charm_test.c src/Charmonizer/Test/VariadicMacros.charm

Author: marvin
Date: Tue Oct 24 12:49:45 2006
New Revision: 467454

URL: http://svn.apache.org/viewvc?view=rev&rev=467454
Log:
Add tests for VariadicMacros module.

Added:
    lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/VariadicMacros.charm
Modified:
    lucene/lucy/trunk/charmonizer/charm_test.c

Modified: lucene/lucy/trunk/charmonizer/charm_test.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/charm_test.c?view=diff&rev=467454&r1=467453&r2=467454
==============================================================================
--- lucene/lucy/trunk/charmonizer/charm_test.c (original)
+++ lucene/lucy/trunk/charmonizer/charm_test.c Tue Oct 24 12:49:45 2006
@@ -14,6 +14,7 @@
     { "FuncMacro", chaz_TestHand_test_FuncMacro },
     { "Integers", chaz_TestHand_test_Integers },
     { "UnusedVars", chaz_TestHand_test_UnusedVars },
+    { "VariadicMacros", chaz_TestHand_test_VariadicMacros },
     { NULL, NULL }
 };
 

Added: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/VariadicMacros.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/VariadicMacros.charm?view=auto&rev=467454
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/VariadicMacros.charm (added)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/VariadicMacros.charm Tue Oct 24 12:49:45 2006
@@ -0,0 +1,67 @@
+#define CHAZ_USE_SHORT_NAMES
+
+#include "_charm_test.h"
+#include "string.h"
+#include "Charmonizer/Test/TestHandler.h"
+
+void 
+chaz_TestHand_test_VariadicMacros(int *num_tests, int *num_passed, 
+                                  int *num_failed, int *num_skipped)
+{
+    int test_num  = 0;
+    *num_tests    = 3;
+    *num_passed   = 0;
+    *num_failed   = 0;
+    *num_skipped  = *num_tests;
+    char buf[10];
+    chaz_bool_t really_has_var_macs = false;
+    int i;
+
+#ifndef HAS_VARIADIC_MACROS
+  #if defined(HAS_ISO_VARIADIC_MACROS) || defined(HAS_GNUC_VARIADIC_MACROS)
+    Assert_True(0, "#defines agree");
+  #else 
+    Assert_True(1, "#defines agree");
+    Skip_Remaining("No variadic macro support");
+  #endif
+#endif
+
+#ifdef HAS_ISO_VARIADIC_MACROS
+ #define ISO_TEST(buffer, fmt, ...) \
+    sprintf(buffer, fmt, __VA_ARGS__)
+    really_has_var_macs = true;
+    ISO_TEST(buf, "%s", "iso");
+    Assert_True((strncmp(buf, "iso", 3) == 0), "ISO variadic macros work");
+#else
+    Skip("No ISO variadic macros");
+#endif
+
+#ifdef HAS_GNUC_VARIADIC_MACROS
+ #define GNU_TEST(buffer, fmt, args...) \
+    sprintf(buffer, fmt, ##args )
+    really_has_var_macs = true;
+    GNU_TEST(buf, "%s", "gnu");
+    Assert_True((strncmp(buf, "gnu", 3) == 0), "GNUC variadic macros work");
+#else
+    Skip("No GNUC variadic macros");
+#endif
+
+    Assert_True(really_has_var_macs, "either ISO or GNUC");
+}
+
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+