[Mesa-dev] [PATCH 7/8] port to gtest

2017-08-29 Thread Thomas Helland
---
 src/util/tests/string_buffer/append_and_print.c   |  99 --
 src/util/tests/string_buffer/append_and_print.cpp | 221 ++
 2 files changed, 221 insertions(+), 99 deletions(-)
 delete mode 100644 src/util/tests/string_buffer/append_and_print.c
 create mode 100644 src/util/tests/string_buffer/append_and_print.cpp

diff --git a/src/util/tests/string_buffer/append_and_print.c 
b/src/util/tests/string_buffer/append_and_print.c
deleted file mode 100644
index 71b857892f..00
--- a/src/util/tests/string_buffer/append_and_print.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright © 2017 Thomas Helland
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- */
-
-#include 
-#include 
-#include 
-#include 
-#include "string_buffer.h"
-
-int
-main(int argc, char **argv)
-{
-   (void) argc;
-   (void) argv;
-
-   struct _mesa_string_buffer *buf;
-   char *str1 = "test1";
-   char *str2 = "test2";
-   char *str3 = "test1test2";
-   char str4[80];
-   char str5[40];
-
-   buf = _mesa_string_buffer_create(NULL, 6);
-
-   /* The string terminator needs one byte, so there should be five left */
-   assert(_mesa_string_buffer_space_left(buf) == 5);
-
-   _mesa_string_buffer_append(buf, str1);
-
-   /* The string should now be full */
-   assert(_mesa_string_buffer_space_left(buf) == 0);
-
-   /* The content should be equal */
-   assert(strcmp(buf->buf, str1) == 0);
-
-   /* Add more, so that the string is resized */
-   _mesa_string_buffer_append(buf, str2);
-
-   /* The size of the buffer should have been doubled.
-* We have 5 + 5 + 1 characters, so there should be one left.
-*/
-   assert(_mesa_string_buffer_space_left(buf) == 1);
-
-   /* The string should now be equal to str3 */
-   assert(strcmp(buf->buf, str3) == 0);
-
-   /* Compile a string with some formatting */
-   sprintf(str4, "Testing formatting %d, %f", 100, 1.0);
-
-   /* Clear the string buffer first */
-   _mesa_string_buffer_clear(buf);
-
-   /* Check that the length of the string is reset */
-   assert(buf->length == 0);
-
-   /* Then test printing some formatted text */
-   _mesa_string_buffer_printf(buf, "Testing formatting %d, %f", 100, 1.0);
-
-   /* The string should now be equal to str4 */
-   assert(strcmp(buf->buf, &str4) == 0);
-
-   /* Compile a string with some other formatting */
-   sprintf(str5, "Testing formatting %d, %x", 100, 0xDEADBEAF);
-
-   /* Concatenate str5 to str4 */
-   strcat(str4, str5);
-
-   /* Now use the formatted append function */
-   _mesa_string_buffer_printf(buf, "Testing formatting %d, %x", 100, 
0xDEADBEAF);
-
-   /* The string buffer should now be equal to str4 */
-   assert(strcmp(buf->buf, &str4) == 0);
-
-   /* Finally, clean up after us */
-   _mesa_string_buffer_destroy(buf);
-
-   return 0;
-}
diff --git a/src/util/tests/string_buffer/append_and_print.cpp 
b/src/util/tests/string_buffer/append_and_print.cpp
new file mode 100644
index 00..c3ccd8f9d1
--- /dev/null
+++ b/src/util/tests/string_buffer/append_and_print.cpp
@@ -0,0 +1,221 @@
+/*
+ * Copyright © 2017 Thomas Helland
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFR

Re: [Mesa-dev] [PATCH 7/8] port to gtest

2017-08-30 Thread Emil Velikov
On 29 August 2017 at 20:56, Thomas Helland  wrote:
> ---
>  src/util/tests/string_buffer/append_and_print.c   |  99 --
>  src/util/tests/string_buffer/append_and_print.cpp | 221 
> ++
>  2 files changed, 221 insertions(+), 99 deletions(-)
>  delete mode 100644 src/util/tests/string_buffer/append_and_print.c
>  create mode 100644 src/util/tests/string_buffer/append_and_print.cpp
>
I think this should be squashed with 2/8. Some Makefile fixes that
would need to be applied:

append_and_print_SOURCES = \
append_and_print.cpp

append_and_print_LDADD = \
$(top_builddir)/src/gtest/libgtest.la


> +++ b/src/util/tests/string_buffer/append_and_print.cpp
> @@ -0,0 +1,221 @@
...
> +int
> +main(int argc, char **argv)
> +{
...
> +}
> +
Seems like copy/paste from the .C file. Do we need it?

...

> \ No newline at end of file

Please add the trailing newline.

-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev