#!/bin/bash

####################
# About validation #
####################
#This file is a template for writing validation code. Validation is meant to
#ensure that data structures stay up to date with the C++ implementation in
#TBTK. Validation is only meant to ensure the that the data structure itself is
#up to date, as opposed to ensuring that the functionality is correct.
#
#The validation works as follows. For any given data structure, a number of
#reference objects are generated by the Validator using the C++ implementation
#of TBTK. Each object is then serialized to JSON. The JSON object should then
#be deserialized using the implementation that is to be validated and then
#reserialized back to JSON. Finally, the new JSON object is read by the
#validator and a check is made to ensure that the object is equal to the
#original reference object produced by the validator.
#
#To run the validation, a command needs to be supplied that is ready to read a
#JSON object from stdin. The cammand should further deserialize the JSON to
#create an object, reserialize it back to JSON, and print the result to stdout.

################################
# Do not change this function. #
################################
function validate(){
	validator=TBTKValidator$1
	numTests=$($validator NumTests)
	for((n=0; n < ${numTests}; n++))
	do
		echo $($validator Get $n | $2 | $validator Validate $n)
	done
}

##################################
# List validation commands here. #
##################################
#Note: This file is meant to be copied to an external folder before being used.
#
#The structure of a validation command is:
validate "DATA_STRUCTURE" "COMMAND"
#DATA_STRUCTURE:
#	The data structure to validate.
#
#COMMAND:
#	A command that reads a JSON from stdin, deserialize it to the given
#	DATA_STRUCTURE, reserialize it back to JSON, and prints the result to
#	stdout.

#Example:
validate "Index" "python Index.py"
