chroma: cvpx: always use cached copy
[vlc.git] / compat / test / strnstr.c
blobeb0337a3de6a990329fb72fa0916d28931a28717
1 /*****************************************************************************
2 * strnstr.c: Test for strnstr implementation API
3 *****************************************************************************
4 * Copyright © 2015 VideoLAN & VLC authors
6 * Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #include "config.h"
25 #include <stdbool.h>
26 #undef NDEBUG
27 #include <assert.h>
28 #include <string.h>
30 const char* haystack = "Lorem ipsum dolor sit amet";
32 static void test( const char* haystack, const char* needle, size_t len, bool res )
34 if ( len == 0 )
35 len = strlen( haystack );
36 char* str = strnstr( haystack, needle, len );
37 assert( res == ( str != NULL ) );
40 int main(void)
42 test( haystack, "Lorem", 0, true );
43 test( haystack, "Sea Otters", 0, false );
44 test( haystack, "", 0, true );
45 test( haystack, "Lorem ipsum dolor sit amet, but bigger", 0, false );
46 test( haystack, haystack, 0, true );
47 test( haystack, "amet", 0, true );
48 test( haystack, "dolor", 5, false );