OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [builtins/] [strcspn.c] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 688 jeremybenn
/* Copyright (C) 2000, 2004  Free Software Foundation.
2
 
3
   Ensure all expected transformations of builtin strcspn occur and
4
   perform correctly.
5
 
6
   Written by Kaveh R. Ghazi, 11/27/2000.  */
7
 
8
extern void abort (void);
9
typedef __SIZE_TYPE__ size_t;
10
extern size_t strcspn (const char *, const char *);
11
extern char *strcpy (char *, const char *);
12
 
13
void
14
main_test (void)
15
{
16
  const char *const s1 = "hello world";
17
  char dst[64], *d2;
18
 
19
  if (strcspn (s1, "hello") != 0)
20
    abort();
21
  if (strcspn (s1, "z") != 11)
22
    abort();
23
  if (strcspn (s1+4, "z") != 7)
24
    abort();
25
  if (strcspn (s1, "hello world") != 0)
26
    abort();
27
  if (strcspn (s1, "") != 11)
28
    abort();
29
  strcpy (dst, s1);
30
  if (strcspn (dst, "") != 11)
31
    abort();
32
  strcpy (dst, s1); d2 = dst;
33
  if (strcspn (++d2, "") != 10 || d2 != dst+1)
34
    abort();
35
  strcpy (dst, s1); d2 = dst;
36
  if (strcspn (++d2+5, "") != 5 || d2 != dst+1)
37
    abort();
38
  if (strcspn ("", s1) != 0)
39
    abort();
40
  strcpy (dst, s1);
41
  if (strcspn ("", dst) != 0)
42
    abort();
43
  strcpy (dst, s1); d2 = dst;
44
  if (strcspn ("", ++d2) != 0 || d2 != dst+1)
45
    abort();
46
  strcpy (dst, s1); d2 = dst;
47
  if (strcspn ("", ++d2+5) != 0 || d2 != dst+1)
48
    abort();
49
 
50
  /* Test at least one instance of the __builtin_ style.  We do this
51
     to ensure that it works and that the prototype is correct.  */
52
  if (__builtin_strcspn (s1, "z") != 11)
53
    abort();
54
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.