/******************************************************************************
 * Copyright (c) 2000-2025 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Raduly, Csaba
 *
 ******************************************************************************/
module shifty_OK {

type component PDTestComponent {};


/*--- SHIFT ON BITSTRING --------------------------------------------------*/

const     bitstring shiconb  := '0000000000'B
const     bitstring shiconb1 := '0000110000'B
modulepar bitstring shiparb  := shiconb
modulepar bitstring shiparb1 := shiconb1
modulepar bitstring shiparb2 := shiconb1 >> 2 // '0000001100'B
modulepar bitstring shiparb3 := shiconb1 << 2 // '0011000000'B
modulepar bitstring shiparb4 := shiconb1 << 5 // '1000000000'B
modulepar bitstring shiparb5 := shiconb1 >> 5 // '0000000001'B
modulepar bitstring shiparb6 := shiconb1 << 0 // '0000110000'B
modulepar bitstring shiparb7 := shiconb1 >> 0 // '0000110000'B
modulepar bitstring shiparb8 := shiconb1 << 11 // '0000000000'B
modulepar bitstring shiparb9 := shiconb1 >> 11 // '0000000000'B
modulepar bitstring shiparb10 := ''B
modulepar bitstring shiparb11 := ''B >> 2
modulepar bitstring shiparb12 := ''B << 2
modulepar bitstring shiparb13 := ''B >> 0
modulepar bitstring shiparb14 := ''B << 0
modulepar bitstring shiparb15 := shiconb1 >> -2 // '0011000000'B
modulepar bitstring shiparb16 := shiconb1 << -2 // '0000001100'B

testcase shift_bitstr() runs on PDTestComponent{

	var integer j;

	if (shiparb1 == shiparb2 << 2)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparb1 == shiparb3 >> 2)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparb1 != shiparb4 >> 5)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparb1 != shiparb5 << 5)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparb1 == shiparb6)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparb1 == shiparb7)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparb == shiparb8)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparb == shiparb9)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if ((shiparb10 == shiparb11)
	and (shiparb10 == shiparb12))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if ((shiparb10 == shiparb13)
	and (shiparb10 == shiparb14))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparb15 == shiparb3)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparb16 == shiparb2)
	     {setverdict(pass);}
	else {setverdict(fail);}

	for (j:=0; j<256; j:=j+1) {
	if (((int2bit(j,10) << 2) >> 2) == int2bit(j,10))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (((int2bit(j,10) << 2) << -2) == int2bit(j,10))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (((int2bit(j,10) >> -2) >> 2) == int2bit(j,10))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (((int2bit(j,10) >> 0) << 0) == int2bit(j,10))
	     {setverdict(pass);}
	else {setverdict(fail);}
	}
}

/*--- SHIFT ON HEXSTRING --------------------------------------------------*/

const     hexstring shiconh  := '0000000000'H
const     hexstring shiconh1 := '0000110000'H
modulepar hexstring shiparh  := shiconh
modulepar hexstring shiparh1 := shiconh1
modulepar hexstring shiparh2 := shiconh1 >> 2 // '0000001100'H
modulepar hexstring shiparh3 := shiconh1 << 2 // '0011000000'H
modulepar hexstring shiparh4 := shiconh1 << 5 // '1000000000'H
modulepar hexstring shiparh5 := shiconh1 >> 5 // '0000000001'H
modulepar hexstring shiparh6 := shiconh1 << 0 // '0000110000'H
modulepar hexstring shiparh7 := shiconh1 >> 0 // '0000110000'H
modulepar hexstring shiparh8 := shiconh1 << 11 // '0000000000'H
modulepar hexstring shiparh9 := shiconh1 >> 11 // '0000000000'H
modulepar hexstring shiparh10 := ''H
modulepar hexstring shiparh11 := ''H >> 2
modulepar hexstring shiparh12 := ''H << 2
modulepar hexstring shiparh13 := ''H >> 0
modulepar hexstring shiparh14 := ''H << 0
modulepar hexstring shiparh15 := shiconh1 >> -2 // '0011000000'H
modulepar hexstring shiparh16 := shiconh1 << -2 // '0000001100'H

testcase shift_hexstr() runs on PDTestComponent{

	var integer j;

	if (shiparh1 == shiparh2 << 2)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparh1 == shiparh3 >> 2)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparh1 != shiparh4 >> 5)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparh1 != shiparh5 << 5)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparh1 == shiparh6)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparh1 == shiparh7)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparh == shiparh8)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparh == shiparh9)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if ((shiparh10 == shiparh11)
	and (shiparh10 == shiparh12))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if ((shiparh10 == shiparh13)
	and (shiparh10 == shiparh14))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparh15 == shiparh3)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparh16 == shiparh2)
	     {setverdict(pass);}
	else {setverdict(fail);}

	for (j:=0; j<256; j:=j+1) {
	if (((int2hex(j,10) << 2) >> 2) == int2hex(j,10))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (((int2hex(j,10) << 2) << -2) == int2hex(j,10))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (((int2hex(j,10) >> -2) >> 2) == int2hex(j,10))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (((int2hex(j,10) >> 0) << 0) == int2hex(j,10))
	     {setverdict(pass);}
	else {setverdict(fail);}
	}
}

/*--- SHIFT ON OCTETSTRING --------------------------------------------------*/

const     octetstring shicono  := '0000000000'O
const     octetstring shicono1 := '0000AA0000'O
modulepar octetstring shiparo  := shicono
modulepar octetstring shiparo1 := shicono1
modulepar octetstring shiparo2 := shicono1 >> 2 // '00000000AA'O
modulepar octetstring shiparo3 := shicono1 << 2 // 'AA00000000'O
modulepar octetstring shiparo4 := shicono1 << 5 // '0000000000'O
modulepar octetstring shiparo5 := shicono1 >> 5 // '0000000000'O
modulepar octetstring shiparo6 := shicono1 << 0 // '0000AA0000'O
modulepar octetstring shiparo7 := shicono1 >> 0 // '0000AA0000'O
modulepar octetstring shiparo8 := shicono1 << 11 // '0000000000'O
modulepar octetstring shiparo9 := shicono1 >> 11 // '0000000000'O
modulepar octetstring shiparo10 := ''O
modulepar octetstring shiparo11 := ''O >> 2
modulepar octetstring shiparo12 := ''O << 2
modulepar octetstring shiparo13 := ''O >> 0
modulepar octetstring shiparo14 := ''O << 0
modulepar octetstring shiparo15 := shicono1 >> -2 // 'AA00000000'O
modulepar octetstring shiparo16 := shicono1 << -2 // '00000000AA'O

testcase shift_octetstr() runs on PDTestComponent{

	var integer j;

	if (shiparo1 == shiparo2 << 2)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparo1 == shiparo3 >> 2)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparo1 != shiparo4 >> 5)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparo1 != shiparo5 << 5)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparo1 == shiparo6)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparo1 == shiparo7)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparo == shiparo8)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparo == shiparo9)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if ((shiparo10 == shiparo11)
	and (shiparo10 == shiparo12))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if ((shiparo10 == shiparo13)
	and (shiparo10 == shiparo14))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparo15 == shiparo3)
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (shiparo16 == shiparo2)
	     {setverdict(pass);}
	else {setverdict(fail);}

	for (j:=0; j<256; j:=j+1) {
	if (((int2oct(j,3) << 2) >> 2) == int2oct(j,3))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (((int2oct(j,3) << 2) << -2) == int2oct(j,3))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (((int2oct(j,3) >> -2) >> 2) == int2oct(j,3))
	     {setverdict(pass);}
	else {setverdict(fail);}
	if (((int2oct(j,3) >> 0) << 0) == int2oct(j,3))
	     {setverdict(pass);}
	else {setverdict(fail);}
	}
}

control {
	execute (shift_bitstr());
	execute (shift_hexstr());
	execute (shift_octetstr());
}

}
