#!/bin/bash
######################################################################################
#
# This script is used for testing the results command from outside the Shell.
#
# Issue:  NXM-4108 nm results from os prompt needs to be tested
# Since:  NeXtMidas 4.1.4
# Author: Zachary Matthews
#
######################################################################################
echo $1
# Check if NMROOT is defined
if [[ -z "${NMROOT}" ]]; then
  echo "WARNING: NMROOT is not defined"
  exit 1
fi

# Check if JAVAHOME is defined
if [[ -z "${JAVA_HOME}" ]]; then
  echo "WARNING: JAVA_HOME is not defined"
  exit 1
fi

# Start new NeXtMidas session
source ${NMROOT}/os/unix/nmstart.sh
echo ""

##############################################################################
# Lower Case
##############################################################################

# Lower case with escaped quotes
source ${NMROOT}/os/unix/nm.sh res x \"abc\"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Lower case to lower case with escaped quotes should match\" x eqs "abc"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Lower case to upper case with escaped quotes should not match\" x neqs "ABC"

# Lower case with no quotes
source ${NMROOT}/os/unix/nm.sh res x abc
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Lower case to lower case with no quotes should match\" x eqs  "abc"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Lower case to upper case with no quotes should not match\" x neqs "ABC"

# Lower case with regular quotes
source ${NMROOT}/os/unix/nm.sh res x "abc"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Lower case to lower case with regular quotes should match\" x eqs  "abc"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Lower case to upper case with regular quotes should not match\" x neqs "ABC"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Lower case to mixed case with regular quotes should not match\" x neqs "AbC"

##############################################################################
# Upper Case
##############################################################################

# Upper case with escaped quotes
source ${NMROOT}/os/unix/nm.sh res x \"ABC\"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Upper case to upper case with escaped quotes should match\" x eqs  "ABC"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Upper case to lower case with escaped quotes should not match\" x neqs "abc"

# Upper case with no quotes
source ${NMROOT}/os/unix/nm.sh res x ABC
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Upper case to upper case with no quotes should match\" x eqs  "ABC"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Upper case to lower case with no quotes should not match\" x neqs "abc"

# Upper case with regular quotes
source ${NMROOT}/os/unix/nm.sh res x "ABC"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Upper case to upper case with regular quotes should match\" x eqs  "ABC"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Upper case to lower case with regular quotes should not match\" x neqs "abc"

##############################################################################
# Mixed Case
##############################################################################

# Mixed case with escaped quotes
source ${NMROOT}/os/unix/nm.sh res x \"AbC\"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Mixed case to mixed case with escaped quotes should match\" x eqs  "AbC"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Mixed case to lower case with escaped quotes should not match\" x neqs "abc"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Mixed case to upper case with escaped quotes should not match\" x neqs "ABC"

# Mixed case with no quotes
source ${NMROOT}/os/unix/nm.sh res x AbC
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Mixed case to mixed case with no quotes should match\" x eqs  "AbC"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Mixed case to lower case with no quotes should not match\" x neqs "abc"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Mixed case to upper case with no quotes should not match\" x neqs "ABC"

# Mixed case with regular quotes
source ${NMROOT}/os/unix/nm.sh res x "AbC"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Mixed case to mixed case with regular quotes should match\" x eqs  "AbC"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Mixed case to lower case with regular quotes should not match\" x neqs "abc"
source ${NMROOT}/os/unix/nm.sh assert/cs/text=\"Mixed case to upper case with regular quotes should not match\" x neqs "ABC"

source ${NMROOT}/os/unix/nmend.sh
