@@ -88,6 +88,71 @@ void test_strvec__pushv(void)
88
88
strvec_clear (& vec );
89
89
}
90
90
91
+ void test_strvec__splice_with_same_size_replacement (void )
92
+ {
93
+ struct strvec vec = STRVEC_INIT ;
94
+ const char * replacement [] = { "1" };
95
+
96
+ strvec_pushl (& vec , "foo" , "bar" , "baz" , NULL );
97
+ strvec_splice (& vec , 1 , 1 , replacement , ARRAY_SIZE (replacement ));
98
+ check_strvec (& vec , "foo" , "1" , "baz" , NULL );
99
+ strvec_clear (& vec );
100
+ }
101
+
102
+ void test_strvec__splice_with_smaller_replacement (void )
103
+ {
104
+ struct strvec vec = STRVEC_INIT ;
105
+ const char * replacement [] = { "1" };
106
+
107
+ strvec_pushl (& vec , "foo" , "bar" , "baz" , NULL );
108
+ strvec_splice (& vec , 1 , 2 , replacement , ARRAY_SIZE (replacement ));
109
+ check_strvec (& vec , "foo" , "1" , NULL );
110
+ strvec_clear (& vec );
111
+ }
112
+
113
+ void test_strvec__splice_with_bigger_replacement (void )
114
+ {
115
+ struct strvec vec = STRVEC_INIT ;
116
+ const char * replacement [] = { "1" , "2" , "3" };
117
+
118
+ strvec_pushl (& vec , "foo" , "bar" , "baz" , NULL );
119
+ strvec_splice (& vec , 0 , 2 , replacement , ARRAY_SIZE (replacement ));
120
+ check_strvec (& vec , "1" , "2" , "3" , "baz" , NULL );
121
+ strvec_clear (& vec );
122
+ }
123
+
124
+ void test_strvec__splice_with_empty_replacement (void )
125
+ {
126
+ struct strvec vec = STRVEC_INIT ;
127
+
128
+ strvec_pushl (& vec , "foo" , "bar" , "baz" , NULL );
129
+ strvec_splice (& vec , 0 , 2 , NULL , 0 );
130
+ check_strvec (& vec , "baz" , NULL );
131
+ strvec_clear (& vec );
132
+ }
133
+
134
+ void test_strvec__splice_with_empty_original (void )
135
+ {
136
+ struct strvec vec = STRVEC_INIT ;
137
+ const char * replacement [] = { "1" , "2" };
138
+
139
+ strvec_pushl (& vec , "foo" , "bar" , "baz" , NULL );
140
+ strvec_splice (& vec , 1 , 0 , replacement , ARRAY_SIZE (replacement ));
141
+ check_strvec (& vec , "foo" , "1" , "2" , "bar" , "baz" , NULL );
142
+ strvec_clear (& vec );
143
+ }
144
+
145
+ void test_strvec__splice_at_tail (void )
146
+ {
147
+ struct strvec vec = STRVEC_INIT ;
148
+ const char * replacement [] = { "1" , "2" };
149
+
150
+ strvec_pushl (& vec , "foo" , "bar" , NULL );
151
+ strvec_splice (& vec , 2 , 0 , replacement , ARRAY_SIZE (replacement ));
152
+ check_strvec (& vec , "foo" , "bar" , "1" , "2" , NULL );
153
+ strvec_clear (& vec );
154
+ }
155
+
91
156
void test_strvec__replace_at_head (void )
92
157
{
93
158
struct strvec vec = STRVEC_INIT ;
0 commit comments