Created SetUp and TearDown functions for testrwops suite.
authorMarkus Kauppila <markus.kauppila@gmail.com>
Sun, 28 Aug 2011 11:55:54 +0300
changeset 5840 802775b331b1
parent 5839 98eed46feb99
child 5841 db409e0e87ad
Created SetUp and TearDown functions for testrwops suite.
test/test-automation/tests/testrwops/testrwops.c
--- a/test/test-automation/tests/testrwops/testrwops.c	Wed Aug 17 12:57:14 2011 +0300
+++ b/test/test-automation/tests/testrwops/testrwops.c	Sun Aug 28 11:55:54 2011 +0300
@@ -13,13 +13,13 @@
 
 #include "../../include/SDL_test.h"
 
-// TODO create these at SetUp() and such TearDown()
-const char* RWOPS_READ = "tests/testrwops/read";
-const char* RWOPS_WRITE = "tests/testrwops/write";
+const char* RWOPS_READ = "rwops_read";
+const char* RWOPS_WRITE = "rwops_write";
 
 static const char hello_world[] = "Hello World!";
 static const char const_mem[] = "Hello World!";
 
+
 /* Test cases */
 static const TestCaseReference test1 =
 		(TestCaseReference){ "rwops_testParam", "test parameters", TEST_ENABLED, 0, 0 };
@@ -54,6 +54,25 @@
 }
 
 
+// Fixture
+void
+SetUp(void *arg)
+{
+	FILE *handle = fopen(RWOPS_READ, "w");
+	AssertTrue(handle != NULL, "Creating file '%s' failed", RWOPS_READ);
+
+	fwrite(hello_world, 1, SDL_strlen(hello_world), handle);
+	fclose(handle);
+}
+
+void
+TearDown(void *arg)
+{
+	// Remove the created files
+	remove(RWOPS_READ);
+	remove(RWOPS_WRITE);
+}
+
 /**
  * @brief Makes sure parameters work properly. Helper function
  *