PageRenderTime 59ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/octave/li_std_string_extra_runme.m

#
MATLAB | 162 lines | 121 code | 41 blank | 0 comment | 30 complexity | e2bd7c88c28d152495c6ceb9536b875b MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. li_std_string_extra
  2. x="hello";
  3. if (li_std_string_extra.test_ccvalue(x) != x)
  4. error("bad string mapping")
  5. endif
  6. if (li_std_string_extra.test_cvalue(x) != x)
  7. error("bad string mapping")
  8. endif
  9. if (li_std_string_extra.test_value(x) != x)
  10. error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x))
  11. endif
  12. if (li_std_string_extra.test_const_reference(x) != x)
  13. error("bad string mapping")
  14. endif
  15. s = li_std_string_extra.string("he");
  16. #s += "ll"
  17. #s.append("ll")
  18. s = s + "llo";
  19. if (s != x)
  20. error("bad string mapping: %s, %s", s, x);
  21. endif
  22. #if (s(1:4) != x(1:4))
  23. # error("bad string mapping")
  24. #endif
  25. if (li_std_string_extra.test_value(s) != x)
  26. error("bad string mapping")
  27. endif
  28. if (li_std_string_extra.test_const_reference(s) != x)
  29. error("bad string mapping")
  30. endif
  31. a = li_std_string_extra.A(s);
  32. if (li_std_string_extra.test_value(a) != x)
  33. error("bad string mapping")
  34. endif
  35. if (li_std_string_extra.test_const_reference(a) != x)
  36. error("bad string mapping")
  37. endif
  38. b = li_std_string_extra.string(" world");
  39. s = a + b;
  40. if (a + b != "hello world")
  41. error("bad string mapping: %s", a + b)
  42. endif
  43. if (a + " world" != "hello world")
  44. error("bad string mapping")
  45. endif
  46. #if ("hello" + b != "hello world")
  47. # error("bad string mapping")
  48. #endif
  49. c = (li_std_string_extra.string("hello") + b);
  50. if (c.find_last_of("l") != 9)
  51. error("bad string mapping")
  52. endif
  53. s = "hello world";
  54. b = li_std_string_extra.B("hi");
  55. b.name = li_std_string_extra.string("hello");
  56. if (b.name != "hello")
  57. error("bad string mapping")
  58. endif
  59. b.a = li_std_string_extra.A("hello");
  60. if (b.a != "hello")
  61. error("bad string mapping")
  62. endif
  63. if (li_std_string_extra.test_value_basic1(x) != x)
  64. error("bad string mapping")
  65. endif
  66. if (li_std_string_extra.test_value_basic2(x) != x)
  67. error("bad string mapping")
  68. endif
  69. if (li_std_string_extra.test_value_basic3(x) != x)
  70. error("bad string mapping")
  71. endif
  72. # Global variables
  73. s = "initial string";
  74. if (li_std_string_extra.cvar.GlobalString2 != "global string 2")
  75. error("GlobalString2 test 1")
  76. endif
  77. li_std_string_extra.cvar.GlobalString2 = s;
  78. if (li_std_string_extra.cvar.GlobalString2 != s)
  79. error("GlobalString2 test 2")
  80. endif
  81. if (li_std_string_extra.cvar.ConstGlobalString != "const global string")
  82. error("ConstGlobalString test")
  83. endif
  84. # Member variables
  85. myStructure = li_std_string_extra.Structure();
  86. if (myStructure.MemberString2 != "member string 2")
  87. error("MemberString2 test 1")
  88. endif
  89. myStructure.MemberString2 = s;
  90. if (myStructure.MemberString2 != s)
  91. error("MemberString2 test 2")
  92. endif
  93. if (myStructure.ConstMemberString != "const member string")
  94. error("ConstMemberString test")
  95. endif
  96. if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2")
  97. error("StaticMemberString2 test 1")
  98. endif
  99. li_std_string_extra.cvar.Structure_StaticMemberString2 = s;
  100. if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s)
  101. error("StaticMemberString2 test 2")
  102. endif
  103. if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string")
  104. error("ConstStaticMemberString test")
  105. endif
  106. if (li_std_string_extra.test_reference_input("hello") != "hello")
  107. error
  108. endif
  109. s = li_std_string_extra.test_reference_inout("hello");
  110. if (s != "hellohello")
  111. error
  112. endif
  113. if (li_std_string_extra.stdstring_empty() != "")
  114. error
  115. endif
  116. if (li_std_string_extra.c_empty() != "")
  117. error
  118. endif
  119. #if (li_std_string_extra.c_null() != None)
  120. # error
  121. #endif