author  Sam Lantinga <slouken@libsdl.org> 
Fri, 24 May 2013 03:23:21 0700  
changeset 7216  3586fc0ba156 
child 7219  c577dfb69153 
permissions  rwrr 
7216
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

1 
/** 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

2 
* Standard C library routine test suite 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

3 
*/ 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

4 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

5 
#include <stdio.h> 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

6 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

7 
#include "SDL.h" 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

8 
#include "SDL_test.h" 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

9 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

10 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

11 
/* Test case functions */ 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

12 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

13 
/** 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

14 
* @brief Call to SDL_strlcpy 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

15 
*/ 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

16 
#undef SDL_strlcpy 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

17 
int 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

18 
stdlib_strlcpy(void *arg) 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

19 
{ 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

20 
size_t result; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

21 
char text[1024]; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

22 
const char *expected; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

23 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

24 
result = SDL_strlcpy(text, "foo", sizeof(text)); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

25 
expected = "foo"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

26 
SDLTest_AssertPass("Call to SDL_strlcpy(\"foo\")"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

27 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

28 
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

29 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

30 
result = SDL_strlcpy(text, "foo", 2); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

31 
expected = "f"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

32 
SDLTest_AssertPass("Call to SDL_strlcpy(\"foo\") with buffer size 2"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

33 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

34 
SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

35 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

36 
return TEST_COMPLETED; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

37 
} 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

38 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

39 
/** 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

40 
* @brief Call to SDL_snprintf 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

41 
*/ 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

42 
#undef SDL_snprintf 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

43 
int 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

44 
stdlib_snprintf(void *arg) 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

45 
{ 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

46 
int result; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

47 
char text[1024]; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

48 
const char *expected; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

49 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

50 
result = SDL_snprintf(text, sizeof(text), "%s", "foo"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

51 
expected = "foo"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

52 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%s\", \"foo\")"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

53 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

54 
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

55 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

56 
result = SDL_snprintf(text, 2, "%s", "foo"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

57 
expected = "f"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

58 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%s\", \"foo\") with buffer size 2"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

59 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

60 
SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

61 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

62 
result = SDL_snprintf(NULL, 0, "%s", "foo"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

63 
SDLTest_AssertCheck(result == 3, "Check result value, expected: 3, got: %d", result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

64 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

65 
result = SDL_snprintf(text, sizeof(text), "%f", 1.0); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

66 
expected = "1.000000"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

67 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%f\", 1.0)"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

68 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

69 
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

70 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

71 
result = SDL_snprintf(text, sizeof(text), "%.f", 1.0); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

72 
expected = "1"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

73 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%.f\", 1.0)"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

74 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

75 
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

76 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

77 
result = SDL_snprintf(text, sizeof(text), "%#.f", 1.0); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

78 
expected = "1."; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

79 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%#.f\", 1.0)"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

80 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

81 
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

82 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

83 
result = SDL_snprintf(text, sizeof(text), "%f", 1.0 + 1.0 / 3.0); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

84 
expected = "1.333333"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

85 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%f\", 1.0 + 1.0 / 3.0)"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

86 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

87 
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

88 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

89 
result = SDL_snprintf(text, sizeof(text), "%+f", 1.0 + 1.0 / 3.0); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

90 
expected = "+1.333333"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

91 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%+f\", 1.0 + 1.0 / 3.0)"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

92 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

93 
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

94 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

95 
result = SDL_snprintf(text, sizeof(text), "%.2f", 1.0 + 1.0 / 3.0); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

96 
expected = "1.33"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

97 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%.2f\", 1.0 + 1.0 / 3.0)"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

98 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

99 
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

100 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

101 
result = SDL_snprintf(text, sizeof(text), "%6.2f", 1.0 + 1.0 / 3.0); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

102 
expected = " 1.33"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

103 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%6.2f\", 1.0 + 1.0 / 3.0)"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

104 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

105 
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

106 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

107 
result = SDL_snprintf(text, sizeof(text), "%06.2f", 1.0 + 1.0 / 3.0); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

108 
expected = "001.33"; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

109 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%06.2f\", 1.0 + 1.0 / 3.0)"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

110 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

111 
SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", SDL_strlen(text), result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

112 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

113 
result = SDL_snprintf(text, 5, "%06.2f", 1.0 + 1.0 / 3.0); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

114 
expected = "001."; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

115 
SDLTest_AssertPass("Call to SDL_snprintf(\"%%06.2f\", 1.0 + 1.0 / 3.0) with buffer size 5"); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

116 
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

117 
SDLTest_AssertCheck(result == 6, "Check result value, expected: 6, got: %d", result); 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

118 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

119 
return TEST_COMPLETED; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

120 
} 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

121 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

122 
/* ================= Test References ================== */ 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

123 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

124 
/* Standard C routine test cases */ 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

125 
static const SDLTest_TestCaseReference stdlibTest1 = 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

126 
{ (SDLTest_TestCaseFp)stdlib_strlcpy, "stdlib_strlcpy", "Call to SDL_strlcpy", TEST_ENABLED }; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

127 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

128 
static const SDLTest_TestCaseReference stdlibTest2 = 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

129 
{ (SDLTest_TestCaseFp)stdlib_snprintf, "stdlib_snprintf", "Call to SDL_sprintf", TEST_ENABLED }; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

130 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

131 
/* Sequence of Standard C routine test cases */ 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

132 
static const SDLTest_TestCaseReference *stdlibTests[] = { 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

133 
&stdlibTest1, &stdlibTest2, NULL 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

134 
}; 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

135 

3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

136 
/* Timer test suite (global) */ 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

137 
SDLTest_TestSuiteReference stdlibTestSuite = { 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

138 
"Standard C routines", 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

139 
NULL, 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

140 
stdlibTests, 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

141 
NULL 
3586fc0ba156
Added the beginning of automated tests for the standard C library routines.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

142 
}; 