Commit 5eb75d77 authored by urbant's avatar urbant
Browse files

Test cases for the select union statement

parent a0e19b06
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:19.3.2, verify that header part of select-union statements cannot contain anything else than union instances
 ** @verdict  pass reject
 ***************************************************/

// The following requirement is tested:
// In the header part of the select union statement a template instance of union 
// type shall be given.

module NegSem_190301_select_union_statement_001 { 

    type component GeneralComp {
	}	
    
    type record R {
        integer intOption optional,
        charstring strOption optional,
        boolean boolOption optional
    }

    testcase TC_NegSem_190301_select_union_statement_001() runs on GeneralComp {
        var R v_rec := { intOption := omit, strOption := "abc", boolOption := omit }
        select union (v_rec) {
            case (intOption) {
                setverdict(pass);
            } case (strOption) {
                setverdict(pass);
            } case (boolOption) {
                setverdict(pass);
            }
        }
	}

	control {
		execute(TC_NegSem_190301_select_union_statement_001());
	}
}
+48 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:19.3.2, verify that uninitialized value cannot be used in select union header
 ** @verdict  pass reject
 ***************************************************/

// The following requirement is tested:
// [The TemplateInstance in the header of the select union statement] shall be 
// at least partially initialized.

module NegSem_190301_select_union_statement_002 { 

    type component GeneralComp {
	}	
    
    type union U {
        integer intOption,
        charstring strOption,
        record {
            integer field1,
            integer field2
        } recOption
    }
    
    type record R {
        U field1,
        integer field2
    }

    testcase TC_NegSem_190301_select_union_statement_002() runs on GeneralComp {
        var R v_rec;
        v_rec.field2 := 3;
        select union (v_rec.field1) {
            case (intOption) {
                setverdict(fail);
            } case (strOption) {
                setverdict(fail);
            } case (recOption) {
                setverdict(pass);
            }
        }
	}

	control {
		execute(TC_NegSem_190301_select_union_statement_002());
	}
}
+45 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:19.3.2, verify that unknown alternatives cannot be use in case statements
 ** @verdict  pass reject
 ***************************************************/

// The following requirement is tested:
// Every Identifier in a case of the select union statement shall be an identifier 
// of an alternative of the union type of the template instance given to the 
// statement's header.

module NegSem_190301_select_union_statement_003 { 

    type component GeneralComp {
	}	
    
    type union U {
        integer intOption,
        charstring strOption,
        record {
            integer field1,
            integer field2
        } recOption
    }

    testcase TC_NegSem_190301_select_union_statement_003() runs on GeneralComp {
        var U v_un := { intOption := 5 }
        select union (v_un) {
            case (intOption) {
                setverdict(pass);
            } case (strOption) {
                setverdict(fail);
            } case (recOption) {
                setverdict(fail);
            } case (boolOption) {
                setverdict(fail);
            }
        }
	}

	control {
		execute(TC_NegSem_190301_select_union_statement_003());
	}
}
+43 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:19.3.2, verify that the same alternative cannot be used in two case statements (simple case)
 ** @verdict  pass reject
 ***************************************************/

// The following requirement is tested:
// No two cases in a select union statement shall have the same case Identifier.

module NegSem_190301_select_union_statement_004 { 

    type component GeneralComp {
	}	
    
    type union U {
        integer intOption,
        charstring strOption,
        record {
            integer field1,
            integer field2
        } recOption
    }

    testcase TC_NegSem_190301_select_union_statement_004() runs on GeneralComp {
        var U v_un := { recOption := - }
        select union (v_un) {
            case (intOption) {
                setverdict(pass);
            } case (strOption) {
                setverdict(fail);
            } case (recOption) {
                setverdict(fail);
            } case (intOption) {
                setverdict(pass);
            }
        }
	}

	control {
		execute(TC_NegSem_190301_select_union_statement_004());
	}
}
+39 −0
Original line number Diff line number Diff line
/***************************************************
 ** @author   STF 487
 ** @version  0.0.1
 ** @purpose  1:19.3.2, verify that the same alternative cannot be used in two case statements (list item)
 ** @verdict  pass reject
 ***************************************************/

// The following requirement is tested:
// No two cases in a select union statement shall have the same case Identifier.

module NegSem_190301_select_union_statement_005 { 

    type component GeneralComp {
	}	
    
    type union U {
        integer intOption,
        charstring strOption,
        record {
            integer field1,
            integer field2
        } recOption
    }

    testcase TC_NegSem_190301_select_union_statement_005() runs on GeneralComp {
        var U v_un := { intOption := 10 }
        select union (v_un) {
            case (intOption, strOption) {
                setverdict(pass);
            } case (recOption, intOption) {
                setverdict(fail);
            }
        }
	}

	control {
		execute(TC_NegSem_190301_select_union_statement_005());
	}
}
Loading