#!/usr/bin/env python3 # -*- coding: utf-8 -*- # This file is under GNU Affero General Public License 3.0 # see LICENSE.txt import pytest import lib_test from lib_test import * # Int def test_func_V_args_V(): (ret,) = func_V_args_V() assert(ret == None) def test_func_Pi_args_V(): (ret,) = func_Pi_args_V() print("RESULT:", ret) assert (ret == 23) def test_func_V_args_Pi(): (ret,arg1) = func_V_args_Pi(23) print("RESULT:", ret, arg1) assert(ret == None) assert(arg1 == 23) def test_func_Pi_args_Pi(): (ret,arg1) = func_Pi_args_Pi(22) print("RESULT:", ret, arg1) assert (ret == 23) assert (arg1 == 22) # @pytest.mark.skip("") def test_func_V_args_pPi(): (ret,arg1) = func_V_args_pPi(22) print("RESULT:", ret, arg1) assert (ret == None) assert (arg1 == 23) def test_func_Pi_args_Pi_pPi_pPi(): (ret, arg1, arg2, arg3) = func_Pi_args_Pi_pPi_pPi(23, 22, 22) print("RESULT:", ret, arg1, arg2, arg3) assert (ret == 23) assert (arg1 == 23) assert (arg2 == 23) assert (arg3 == 23) # Char def test_func_Pc_args_V(): (ret,) = func_Pc_args_V() print("RESULT:", ret) assert (ret == "A") def test_func_V_args_Pc(): (ret,arg1) = func_V_args_Pc('A') print("RESULT:", ret, arg1) assert(ret == None) assert(arg1 == 'A') def test_func_V_args_Pc_with_Str(): with pytest.raises(Exception): (ret,arg1) = func_V_args_Pc('pEp') def test_func_Pc_args_Pc(): (ret,arg1) = func_Pc_args_Pc('a') print("RESULT:", ret, arg1) assert (ret == 'A') assert (arg1 == 'a') # char* def test_func_pPcStr_args_V(): (ret,) = func_pPcStr_args_V() print("RESULT:", ret) assert (ret == "pEp") def test_func_V_args_pPcChr(): (ret,arg1) = func_V_args_pPcChr('a') print("RESULT:", ret, arg1) assert (ret == None) assert (arg1 == 'A') def test_func_V_args_pPcChr_with_Str(): (ret,arg1) = func_V_args_pPcChr('pep') print("RESULT:", ret, arg1) assert (ret == None) assert (arg1 == 'Pep') def test_func_V_args_pPcStr(): (ret,arg1) = func_V_args_pPcStr('pep') print("RESULT:", ret, arg1) assert (ret == None) assert (arg1 == 'PEP') def test_func_V_args_pPcChr_with_Str_with_Chr(): (ret,arg1) = func_V_args_pPcChr('a') print("RESULT:", ret, arg1) assert (ret == None) assert (arg1 == 'A') def test_func_Pc_args_Pc_pPc_pPc(): (ret, arg1, arg2, arg3) = func_Pc_args_Pc_pPc_pPc('A', 'a','a') print("RESULT:", ret, arg1, arg2, arg3) assert (ret == 'A') assert (arg1 == 'A') assert (arg2 == 'A') assert (arg3 == 'A') # String-by-value (const char*) def test_func_pPcc_args_V(): (ret,) = func_pPcc_args_V() print("RESULT:", ret) assert (ret == "pEp") def test_func_V_args_pPcc(): instr = "pEp" (ret,arg1) = func_V_args_pPcc(instr) print("RESULT:", ret,arg1) assert (ret == None) assert (arg1 == instr) def test_func_pPcc_args_pPcc(): instr = "pEp" (ret,arg1) = func_pPcc_args_pPcc(instr) print("RESULT:", ret,arg1) assert (ret == instr) assert (arg1 == instr) def test_func_pPcc_args_pPcc_pPcc(): instr = "pEp" instr2 = "pEp" (ret,arg1,arg2) = func_pPcc_args_pPcc_pPcc(instr,instr2) print("RESULT:", ret,arg1,arg2) assert (ret == instr) assert (arg1 == instr) assert (arg2 == instr) def test_func_ppPc_args_V(): (ret,) = func_ppPc_args_V() print("RESULT:", ret) assert (ret == "pEp") def test_func_pppPc_args_V(): (ret,) = func_pppPc_args_V() print("RESULT:", ret) assert (ret == "pEp") def test_func_V_args_ppPc(): instr = "orig" (ret,arg1) = func_V_args_ppPc(instr) print("RESULT:", ret,arg1) assert (ret == None) assert (arg1 == "pEp") def test_func_pppPc_args_pppPc(): instr = "orig" (ret,arg1) = func_pppPc_args_pppPc(instr) print("RESULT:", ret,arg1) assert (ret == "pEp") assert (arg1 == "pEp") # # def test_func_ppPc_args_ppPc_ppPc(): # instr = "orig" # instr2 = "orig" # (ret,arg1,arg2) = func_ppPc_args_ppPc_ppPc(instr,instr2) # print("RESULT:", ret,arg1,arg2) # assert (ret == "pEp") # assert (arg1 == "pEp") # assert (arg2 == "pEp") def test_func__PS_args_V(): (ret,) = func__PS_args_V() print(PS_to_string(ret)) assert(ret.field__P_1 == 23); assert(ret.field__P_2 == 23); def test_func_TTAPS_args_V(): (ret,) = func_TTAPS_args_V() print(PS_to_string(ret)) assert(ret.field__P_1 == 23); assert(ret.field__P_2 == 23); def test_func_pTAPS_args_V(): (ret,) = func_pTAPS_args_V() print(PS_to_string(ret)) assert(ret.field__P_1 == 23); assert(ret.field__P_2 == 23); def test_func_ppTAPS_args_V(): (ret,) = func_ppTAPS_args_V() print(PS_to_string(ret)) assert(ret.field__P_1 == 23); assert(ret.field__P_2 == 23); def test_func_pppTAPS_args_V(): (ret,) = func_ppTAPS_args_V() print(PS_to_string(ret)) assert(ret.field__P_1 == 23); assert(ret.field__P_2 == 23); def test_func_V_args_pTAPS(): ps = PS() print(PS_to_string(ps)) (ret,psnew) = func_V_args_pTAPS(ps) print(PS_to_string(psnew)) assert(ret == None); assert(psnew.field__P_1 == 23); assert(psnew.field__P_2 == 23); def PS_to_string(ps): ret = "{}\n".format(type(ps)) ret += "field__P_1: {}\n".format(ps.field__P_1); ret += "field__P_2: {}".format(ps.field__P_2); return ret