File: tst_replace.c

package info (click to toggle)
ustr 1.0.4-6.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,676 kB
  • sloc: ansic: 19,041; makefile: 935; perl: 779; sh: 686; xml: 97
file content (15 lines) | stat: -rw-r--r-- 284 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "ustr.h"

int main(void)
{
  Ustr *s1 = USTR1(\2, "14");
  const char *ptr = NULL;
  
  if (ustr_replace(&s1, USTR1(\1, "4"), USTR1(\2, "21"), 0) != 1)
    return 1;
  ptr = ustr_cstr(s1);
  if (ptr[0] != '1' || ptr[1] != '2' || ptr[2] != '1')
    return 1;
  
  return 0;
}