File: li_std_string.scm

package info (click to toggle)
swig 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 45,980 kB
  • sloc: cpp: 54,284; ansic: 29,022; java: 17,595; python: 12,734; cs: 10,421; ruby: 7,263; yacc: 6,501; makefile: 5,860; javascript: 5,538; sh: 5,422; perl: 4,246; php: 3,733; ml: 2,198; tcl: 2,015; lisp: 1,448; xml: 115
file content (71 lines) | stat: -rw-r--r-- 2,330 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
; The test string has some non-ascii characters added
; because our guile wrappers had bugs in that area
(define x "hello - æææ")

(if (not (string=? (test-value x) x))
  (begin (error "Error 1") (exit 1)))

(if (not (string=? (test-const-reference x) x))
  (begin (error "Error 2") (exit 1)))

(define y (test-pointer-out))
(test-pointer y)
(define z (test-const-pointer-out))
(test-const-pointer z)

(define a (test-reference-out))
(test-reference a)

;; test global variables
(GlobalString "whee")
(if (not (string=? (GlobalString) "whee"))
  (error "Error 3"))
(if (not (string=? (GlobalString2) "global string 2"))
  (error "Error 4"))

(define struct (new-Structure))

;; MemberString should be a wrapped class
(define scl (Structure-MemberString-get struct))
(if (not (string=? scl ""))
  (error "Error 4.5"))
(Structure-MemberString-set struct "and how")
(if (not (string=? (Structure-MemberString-get struct) "and how"))
  (error "Error 5"))
(if (not (string=? (Structure-MemberString2-get struct) "member string 2"))
  (error "Error 6"))
(Structure-StaticMemberString "static str")
(if (not (string=? (Structure-StaticMemberString) "static str"))
  (error "Error 7"))
(if (not (string=? (Structure-StaticMemberString2) "static member string 2"))
  (error "Error 8"))

;(if (not (string=? (Structure-ConstMemberString-get struct) "const member string"))
;  (error "Error 9"))
(if (not (string=? (Structure-ConstStaticMemberString) "const static member string"))
  (error "Error 10"))

(if (not (string=? (stdstring-empty) ""))
  (error "stdstring-empty test"))
(if (not (string=? (c-empty) ""))
  (error "c-empty test"))
; C++ NULL is mapped to #f (false) here rather than null.  I don't know guile
; enough to know if that makes sense or not.
(if (c-null)
  (error "c-null test"))
; FIXME: However, #f doesn't round-trip, so something seems wrong.
; (if (get-null (c-null))
;   (error "get-null c-empty test"))
(if (not (string=? (get-null (c-empty)) "non-null"))
  (error "get-null c-empty test"))
(if (not (string=? (get-null (stdstring-empty)) "non-null"))
  (error "get-null stdstring-empty test"))

(if (not (string=? (aString) "something"))
  (error "aString test"))
(if (not (string=? (MY-STRING) ""))
  (error "MY-STRING test"))
(if (not (string=? (MY-STRING-2) "OK"))
  (error "MY-STRING-2 test"))

(exit 0)