Merge in new scanner/parser suite with updated test cases.
[awesomized/libmemcached] / libtest / test.h
index cc0fd78aaaf21c8e5614c0776fdf4631ea355d76..88cc01157076de68fa000ce69b2cce0c1bbab239 100644 (file)
@@ -1,19 +1,49 @@
-/* uTest
- * Copyright (C) 2006-2009 Brian Aker
- * All rights reserved.
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  Gearmand client and server library.
+ *
+ *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *  Copyright (C) 2006-2010 Brian Aker
+ *  All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are
+ *  met:
+ *
+ *      * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ *
+ *      * Redistributions in binary form must reproduce the above
+ *  copyright notice, this list of conditions and the following disclaimer
+ *  in the documentation and/or other materials provided with the
+ *  distribution.
+ *
+ *      * The names of its contributors may not be used to endorse or
+ *  promote products derived from this software without specific prior
+ *  written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * Use and distribution licensed under the BSD license.  See
- * the COPYING file in the parent directory for full text.
  */
 
+#pragma once
+
+#include <libtest/visibility.h>
+
 /*
   Structures for generic tests.
 */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -39,9 +69,6 @@ typedef test_return_t (*test_callback_fn)(void *);
 typedef test_return_t (*test_callback_runner_fn)(test_callback_fn, void *);
 typedef test_return_t (*test_callback_error_fn)(test_return_t, void *);
 
-/* Help function for use with gettimeofday() */
-long int timedif(struct timeval a, struct timeval b);
-
 /**
   A structure describing the test case.
 */
@@ -139,14 +166,25 @@ typedef struct {
   uint32_t total;
 } world_stats_st;
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Help function for use with gettimeofday() */
+LIBTEST_API
+long int timedif(struct timeval a, struct timeval b);
+
 /* How we make all of this work :) */
+LIBTEST_API
 void get_world(world_st *world);
 
+LIBTEST_INTERNAL_API
 void create_core(void);
 
 /**
   @note Friendly print function for errors.
 */
+LIBTEST_API
 const char *test_strerror(test_return_t code);
 
 #define test_fail(A) \
@@ -200,6 +238,23 @@ do \
   } \
 } while (0)
 
+
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+#define AT __FILE__ ":" TOSTRING(__LINE__)
+
+#ifdef __cplusplus
+#define STRING_WITH_LEN(X) (X), (static_cast<size_t>((sizeof(X) - 1)))
+#else
+#define STRING_WITH_LEN(X) (X), ((size_t)((sizeof(X) - 1)))
+#endif
+
+#ifdef __cplusplus
+#define STRING_PARAM_WITH_LEN(X) X, static_cast<size_t>(sizeof(X) - 1)
+#else
+#define STRING_PARAM_WITH_LEN(X) X, (size_t)((sizeof(X) - 1))
+#endif
+
 #ifdef __cplusplus
 }
 #endif