1: %%----------------------------------------------------------------- 2: %% 3: %% %CopyrightBegin% 4: %% 5: %% Copyright Ericsson AB 2002-2011. All Rights Reserved. 6: %% 7: %% The contents of this file are subject to the Erlang Public License, 8: %% Version 1.1, (the "License"); you may not use this file except in 9: %% compliance with the License. You should have received a copy of the 10: %% Erlang Public License along with this software. If not, it can be 11: %% retrieved online at http://www.erlang.org/. 12: %% 13: %% Software distributed under the License is distributed on an "AS IS" 14: %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 15: %% the License for the specific language governing rights and limitations 16: %% under the License. 17: %% 18: %% %CopyrightEnd% 19: %% 20: %% 21: %%----------------------------------------------------------------- 22: %% File : data_types_SUITE.erl 23: %% Purpose : 24: %%----------------------------------------------------------------- 25: 26: -module(data_types_SUITE). 27: 28: -include_lib("test_server/include/test_server.hrl"). 29: -include_lib("orber/include/corba.hrl"). 30: 31: -define(default_timeout, ?t:minutes(3)). 32: 33: -define(match(ExpectedRes, Expr), 34: fun() -> 35: AcTuAlReS = (catch (Expr)), 36: case AcTuAlReS of 37: ExpectedRes -> 38: io:format("------ CORRECT RESULT ------~n~p~n", 39: [AcTuAlReS]), 40: AcTuAlReS; 41: _ -> 42: io:format("###### ERROR ERROR ######~n~p~n", 43: [AcTuAlReS]), 44: ?line exit(AcTuAlReS) 45: end 46: end()). 47: 48: %%----------------------------------------------------------------- 49: %% External exports 50: %%----------------------------------------------------------------- 51: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 52: init_per_group/2,end_per_group/2]). 53: 54: %%----------------------------------------------------------------- 55: %% Internal exports 56: %%----------------------------------------------------------------- 57: -compile(export_all). 58: 59: %%----------------------------------------------------------------- 60: %% Func: all/1 61: %% Args: 62: %% Returns: 63: %%----------------------------------------------------------------- 64: suite() -> [{ct_hooks,[ts_install_cth]}]. 65: 66: all() -> 67: [fixed_type, any_type]. 68: 69: groups() -> 70: []. 71: 72: init_per_suite(Config) -> 73: Config. 74: 75: end_per_suite(_Config) -> 76: ok. 77: 78: init_per_group(_GroupName, Config) -> 79: Config. 80: 81: end_per_group(_GroupName, Config) -> 82: Config. 83: 84: 85: %%----------------------------------------------------------------- 86: %% Init and cleanup functions. 87: %%----------------------------------------------------------------- 88: init_per_testcase(_Case, Config) -> 89: Path = code:which(?MODULE), 90: code:add_pathz(filename:join(filename:dirname(Path), "idl_output")), 91: ?line Dog=test_server:timetrap(?default_timeout), 92: [{watchdog, Dog}|Config]. 93: 94: 95: end_per_testcase(_Case, Config) -> 96: Path = code:which(?MODULE), 97: code:del_path(filename:join(filename:dirname(Path), "idl_output")), 98: Dog = ?config(watchdog, Config), 99: test_server:timetrap_cancel(Dog), 100: ok. 101: 102: 103: %%----------------------------------------------------------------- 104: %% Test Case: name component handling tests 105: %% Description: 106: %%----------------------------------------------------------------- 107: fixed_type(doc) -> ["Test the Fixed Point Datatype."]; 108: fixed_type(suite) -> []; 109: fixed_type(_) -> 110: Val1 = ?match({fixed,3,2,314}, orber_test_server:val1()), 111: _Val2 = ?match({fixed,3,2,314}, orber_test_server:val2()), 112: _Val3 = ?match({fixed,3,2,314}, orber_test_server:val3()), 113: Val4 = ?match({fixed,3,2,314}, orber_test_server:val4()), 114: Val5 = ?match({fixed,2,2,14}, orber_test_server:val5()), 115: _Val6 = ?match({fixed,1,0,3}, orber_test_server:val6()), 116: Val7 = ?match({fixed,2,2,-14}, orber_test_server:val7()), 117: _Val8 = ?match({fixed,1,0,-3}, orber_test_server:val8()), 118: Val9 = ?match({fixed,3,2,328}, orber_test_server:val9()), 119: Val10 = ?match({fixed,4,4,4396}, orber_test_server:val10()), 120: Val11 = ?match({fixed,31,29,2242857142857142857142857142857}, orber_test_server:val11()), 121: Val12 = ?match({fixed,9,6,123140001}, orber_test_server:val12()), 122: Val13 = ?match({fixed,9,1,123140001}, orber_test_server:val13()), 123: Val14 = ?match({fixed,14,6,-12313876959999}, orber_test_server:val14()), 124: Val15 = ?match({fixed,14,6,12314123240001}, orber_test_server:val15()), 125: Val16 = ?match({fixed,17,7,15163459846280001}, orber_test_server:val16()), 126: _Val17 = ?match({fixed,3,2,402}, orber_test_server:val17()), 127: _Val18 = ?match({fixed,5,4,40401}, orber_test_server:val18()), 128: _Val19 = ?match({fixed,3,0,200}, orber_test_server:val19()), 129: Val20 = ?match({fixed,31,0,1999999999999999999999999999999}, orber_test_server:val20()), 130: Val21 = ?match({fixed,1,0,0}, orber_test_server:val21()), 131: Val22 = ?match({fixed,31,0,9999999999999999999999999999998}, orber_test_server:val22()), 132: Val23 = ?match({fixed,1,0,1}, orber_test_server:val23()), 133: _Val24 = ?match({fixed,5,0,19998}, orber_test_server:val24()), 134: _Val25 = ?match({fixed,2,0,40}, orber_test_server:val25()), 135: Val26 = ?match({fixed,31,0,9999999999999999999999999999999}, orber_test_server:val26()), 136: 137: ?match(Val1, fixed:create(3,2,314)), 138: Val27 = ?match({fixed,6,2,314}, fixed:create(6,2,314)), 139: 140: ?match({tk_fixed,3,2}, fixed:get_typecode(Val1)), 141: ?match({tk_fixed,6,2}, fixed:get_typecode(Val27)), 142: ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, fixed:create(3,2,3140)), 143: ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, fixed:create(5,6,314)), 144: ?match({'EXCEPTION',{'BAD_PARAM',_,_,_}}, fixed:create(32,2,314)), 145: ?match(Val10, fixed:multiply(Val4, Val5)), 146: ?match(Val16, fixed:multiply(Val12, Val13)), 147: ?match(Val22, fixed:multiply(Val26, Val26)), 148: 149: ?match(Val9, fixed:add(Val4, Val5)), 150: ?match(Val15, fixed:add(Val12, Val13)), 151: ?match(Val20, fixed:add(Val26, Val26)), 152: 153: ?match(Val11, fixed:divide(Val4, Val5)), 154: ?match(Val23, fixed:divide(Val26, Val26)), 155: 156: ?match(Val14, fixed:subtract(Val12, Val13)), 157: ?match(Val21, fixed:subtract(Val26, Val26)), 158: 159: ?match(Val7, fixed:unary_minus(Val5)), 160: ?match(Val5, fixed:unary_minus(Val7)), 161: 162: 163: 164: ok. 165: 166: %%----------------------------------------------------------------- 167: %% Test Case: any type 168: %% Description: 169: %%----------------------------------------------------------------- 170: any_type(doc) -> ["Test the Any Datatype."]; 171: any_type(suite) -> []; 172: any_type(_) -> 173: ?match(#any{typecode=undefined, value=undefined}, 174: any:create()), 175: ?match(#any{typecode=tk_short, value=undefined}, 176: any:set_typecode(any:create(), tk_short)), 177: ?match({'EXCEPTION', #'BAD_TYPECODE'{}}, 178: any:set_typecode(any:create(), "wrong")), 179: ?match({'EXCEPTION', #'BAD_TYPECODE'{}}, 180: any:create("wrong", 1)), 181: ?match(#any{typecode=tk_short, value = 1}, 182: any:create(tk_short, 1)), 183: ?match(tk_short, 184: any:get_typecode(any:create(tk_short, 1))), 185: ?match(1, 186: any:get_value(any:create(tk_short, 1))), 187: ?match(#any{typecode=tk_short, value=2}, 188: any:set_value(any:create(tk_short, 1), 2)), 189: 190: ok.