Skip to content

Commit 35f5211

Browse files
Copilott-b
andcommitted
Add GetEmptyWavesOfAllTypes data generator and update IsXXXWave tests; fix case sensitivity test
Co-authored-by: t-b <[email protected]>
1 parent 543357a commit 35f5211

File tree

2 files changed

+107
-184
lines changed

2 files changed

+107
-184
lines changed

Packages/tests/Basic/UTF_Utils_Checks.ipf

Lines changed: 55 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -726,134 +726,65 @@ End
726726
/// IsTextWave
727727
/// @{
728728

729-
// UTF_TD_GENERATOR s0:DataGenerators#GetSupportedWaveTypes
729+
// UTF_TD_GENERATOR w0:DataGenerators#GetEmptyWavesOfAllTypes
730730
Function ITW_Works([STRUCT IUTF_mData &m])
731731

732-
string typeStr
733-
variable type
734-
735-
typeStr = m.s0
736-
737-
strswitch(typeStr)
738-
case "TEXT_WAVE":
739-
Make/FREE/T wvText
740-
WAVE wv = wvText
741-
CHECK(IsTextWave(wv))
742-
break
743-
case "WAVE_WAVE":
744-
Make/FREE/WAVE wvWave
745-
WAVE wv = wvWave
746-
CHECK(!IsTextWave(wv))
747-
break
748-
default:
749-
type = WaveTypeStringToNumber(typeStr)
750-
Make/FREE/Y=(type) wv
751-
CHECK(!IsTextWave(wv))
752-
break
753-
endswitch
732+
WAVE wv = m.w0
733+
734+
// Use WaveType to determine the expected result
735+
variable waveTypeValue = WaveType(wv, 1)
736+
variable expected = (waveTypeValue == 2) // 2 means text wave
737+
738+
CHECK_EQUAL_VAR(IsTextWave(wv), expected)
754739
End
755740

756741
/// @}
757742

758743
/// IsNumericWave
759744
/// @{
760745

761-
// UTF_TD_GENERATOR s0:DataGenerators#GetSupportedWaveTypes
746+
// UTF_TD_GENERATOR w0:DataGenerators#GetEmptyWavesOfAllTypes
762747
Function INW_Works([STRUCT IUTF_mData &m])
763748

764-
string typeStr
765-
variable type
766-
767-
typeStr = m.s0
768-
769-
strswitch(typeStr)
770-
case "TEXT_WAVE":
771-
Make/FREE/T wvText
772-
WAVE wv = wvText
773-
CHECK(!IsNumericWave(wv))
774-
break
775-
case "WAVE_WAVE":
776-
Make/FREE/WAVE wvWave
777-
WAVE wv = wvWave
778-
CHECK(!IsNumericWave(wv))
779-
break
780-
default:
781-
type = WaveTypeStringToNumber(typeStr)
782-
Make/FREE/Y=(type) wv
783-
CHECK(IsNumericWave(wv))
784-
break
785-
endswitch
749+
WAVE wv = m.w0
750+
751+
// Use WaveType to determine the expected result
752+
variable waveTypeValue = WaveType(wv, 1)
753+
variable expected = (waveTypeValue == 1) // 1 means numeric wave
754+
755+
CHECK_EQUAL_VAR(IsNumericWave(wv), expected)
786756
End
787757

788758
/// @}
789759

790760
/// IsWaveRefWave
791761
/// @{
792762

793-
// UTF_TD_GENERATOR s0:DataGenerators#GetSupportedWaveTypes
763+
// UTF_TD_GENERATOR w0:DataGenerators#GetEmptyWavesOfAllTypes
794764
Function IWRW_Works([STRUCT IUTF_mData &m])
795765

796-
string typeStr
797-
variable type
798-
799-
typeStr = m.s0
800-
801-
strswitch(typeStr)
802-
case "TEXT_WAVE":
803-
Make/FREE/T wvText
804-
WAVE wv = wvText
805-
CHECK(!IsWaveRefWave(wv))
806-
break
807-
case "WAVE_WAVE":
808-
Make/FREE/WAVE wvWave
809-
WAVE wv = wvWave
810-
CHECK(IsWaveRefWave(wv))
811-
break
812-
default:
813-
type = WaveTypeStringToNumber(typeStr)
814-
Make/FREE/Y=(type) wv
815-
CHECK(!IsWaveRefWave(wv))
816-
break
817-
endswitch
766+
WAVE wv = m.w0
767+
768+
// Use WaveType to determine the expected result
769+
variable waveTypeValue = WaveType(wv, 1)
770+
variable expected = (waveTypeValue == IGOR_TYPE_WAVEREF_WAVE) // Wave reference wave
771+
772+
CHECK_EQUAL_VAR(IsWaveRefWave(wv), expected)
818773
End
819774

820775
/// @}
821776

822777
/// IsFloatingPointWave
823778
/// @{
824779

825-
// UTF_TD_GENERATOR s0:DataGenerators#GetSupportedWaveTypes
780+
// UTF_TD_GENERATOR w0:DataGenerators#GetEmptyWavesOfAllTypes
826781
Function IFPW_Works([STRUCT IUTF_mData &m])
827782

828-
string typeStr
829-
variable type
830-
variable expected
831-
832-
typeStr = m.s0
833-
834-
strswitch(typeStr)
835-
case "TEXT_WAVE":
836-
Make/FREE/T wvText
837-
WAVE wv = wvText
838-
expected = 0
839-
break
840-
case "WAVE_WAVE":
841-
Make/FREE/WAVE wvWave
842-
WAVE wv = wvWave
843-
expected = 0
844-
break
845-
case "NT_FP64":
846-
case "NT_FP32":
847-
type = WaveTypeStringToNumber(typeStr)
848-
Make/FREE/Y=(type) wv
849-
expected = 1
850-
break
851-
default:
852-
type = WaveTypeStringToNumber(typeStr)
853-
Make/FREE/Y=(type) wv
854-
expected = 0
855-
break
856-
endswitch
783+
WAVE wv = m.w0
784+
785+
// Check if it's a floating point wave (32-bit or 64-bit)
786+
variable waveTypeValue = WaveType(wv)
787+
variable expected = !!(waveTypeValue & (IGOR_TYPE_32BIT_FLOAT | IGOR_TYPE_64BIT_FLOAT))
857788

858789
CHECK_EQUAL_VAR(IsFloatingPointWave(wv), expected)
859790
End
@@ -863,37 +794,14 @@ End
863794
/// IsDoubleFloatingPointWave
864795
/// @{
865796

866-
// UTF_TD_GENERATOR s0:DataGenerators#GetSupportedWaveTypes
797+
// UTF_TD_GENERATOR w0:DataGenerators#GetEmptyWavesOfAllTypes
867798
Function IDFPW_Works([STRUCT IUTF_mData &m])
868799

869-
string typeStr
870-
variable type
871-
variable expected
872-
873-
typeStr = m.s0
874-
875-
strswitch(typeStr)
876-
case "TEXT_WAVE":
877-
Make/FREE/T wvText
878-
WAVE wv = wvText
879-
expected = 0
880-
break
881-
case "WAVE_WAVE":
882-
Make/FREE/WAVE wvWave
883-
WAVE wv = wvWave
884-
expected = 0
885-
break
886-
case "NT_FP64":
887-
type = WaveTypeStringToNumber(typeStr)
888-
Make/FREE/Y=(type) wv
889-
expected = 1
890-
break
891-
default:
892-
type = WaveTypeStringToNumber(typeStr)
893-
Make/FREE/Y=(type) wv
894-
expected = 0
895-
break
896-
endswitch
800+
WAVE wv = m.w0
801+
802+
// Check if it's a double precision (64-bit) floating point wave
803+
variable waveTypeValue = WaveType(wv)
804+
variable expected = !!(waveTypeValue & IGOR_TYPE_64BIT_FLOAT)
897805

898806
CHECK_EQUAL_VAR(IsDoubleFloatingPointWave(wv), expected)
899807
End
@@ -903,37 +811,14 @@ End
903811
/// IsSingleFloatingPointWave
904812
/// @{
905813

906-
// UTF_TD_GENERATOR s0:DataGenerators#GetSupportedWaveTypes
814+
// UTF_TD_GENERATOR w0:DataGenerators#GetEmptyWavesOfAllTypes
907815
Function ISFPW_Works([STRUCT IUTF_mData &m])
908816

909-
string typeStr
910-
variable type
911-
variable expected
912-
913-
typeStr = m.s0
914-
915-
strswitch(typeStr)
916-
case "TEXT_WAVE":
917-
Make/FREE/T wvText
918-
WAVE wv = wvText
919-
expected = 0
920-
break
921-
case "WAVE_WAVE":
922-
Make/FREE/WAVE wvWave
923-
WAVE wv = wvWave
924-
expected = 0
925-
break
926-
case "NT_FP32":
927-
type = WaveTypeStringToNumber(typeStr)
928-
Make/FREE/Y=(type) wv
929-
expected = 1
930-
break
931-
default:
932-
type = WaveTypeStringToNumber(typeStr)
933-
Make/FREE/Y=(type) wv
934-
expected = 0
935-
break
936-
endswitch
817+
WAVE wv = m.w0
818+
819+
// Check if it's a single precision (32-bit) floating point wave
820+
variable waveTypeValue = WaveType(wv)
821+
variable expected = !!(waveTypeValue & IGOR_TYPE_32BIT_FLOAT)
937822

938823
CHECK_EQUAL_VAR(IsSingleFloatingPointWave(wv), expected)
939824
End
@@ -958,30 +843,16 @@ End
958843
/// IsComplexWave
959844
/// @{
960845

961-
// UTF_TD_GENERATOR s0:DataGenerators#GetSupportedWaveTypes
846+
// UTF_TD_GENERATOR w0:DataGenerators#GetEmptyWavesOfAllTypes
962847
Function ICW_Works([STRUCT IUTF_mData &m])
963848

964-
string typeStr
965-
variable type
966-
967-
typeStr = m.s0
849+
WAVE wv = m.w0
968850

969-
strswitch(typeStr)
970-
case "TEXT_WAVE":
971-
Make/FREE/T wvText
972-
WAVE wv = wvText
973-
break
974-
case "WAVE_WAVE":
975-
Make/FREE/WAVE wvWave
976-
WAVE wv = wvWave
977-
break
978-
default:
979-
type = WaveTypeStringToNumber(typeStr)
980-
Make/FREE/Y=(type) wv
981-
break
982-
endswitch
851+
// Check if it's a complex wave
852+
variable waveTypeValue = WaveType(wv)
853+
variable expected = !!(waveTypeValue & IGOR_TYPE_COMPLEX)
983854

984-
CHECK(!IsComplexWave(wv))
855+
CHECK_EQUAL_VAR(IsComplexWave(wv), expected)
985856
End
986857

987858
Function ICW_WorksWithComplexWave()
@@ -1061,14 +932,14 @@ End
1061932

1062933
Function LHOUE_WorksWithDifferentCase()
1063934

1064-
// cmpstr is case-sensitive, so different cases should not match
1065-
CHECK(!ListHasOnlyOneUniqueEntry("a;A"))
1066-
CHECK(!ListHasOnlyOneUniqueEntry("A;a"))
1067-
CHECK(!ListHasOnlyOneUniqueEntry("test;Test"))
1068-
CHECK(!ListHasOnlyOneUniqueEntry("TEST;test"))
1069-
CHECK(!ListHasOnlyOneUniqueEntry("Hello;hello;HELLO"))
935+
// cmpstr is case-insensitive, so different cases should match
936+
CHECK(ListHasOnlyOneUniqueEntry("a;A"))
937+
CHECK(ListHasOnlyOneUniqueEntry("A;a"))
938+
CHECK(ListHasOnlyOneUniqueEntry("test;Test"))
939+
CHECK(ListHasOnlyOneUniqueEntry("TEST;test"))
940+
CHECK(ListHasOnlyOneUniqueEntry("Hello;hello;HELLO"))
1070941

1071-
// Same case should match
942+
// Same case should also match
1072943
CHECK(ListHasOnlyOneUniqueEntry("a;a;a"))
1073944
CHECK(ListHasOnlyOneUniqueEntry("A;A;A"))
1074945
CHECK(ListHasOnlyOneUniqueEntry("Test;Test"))

Packages/tests/UTF_DataGenerators.ipf

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,3 +1994,55 @@ static Function/WAVE GetPSXHelperAxisTypes()
19941994

19951995
return wv
19961996
End
1997+
1998+
/// @brief Returns a wave reference wave holding an empty wave of each Igor Pro supported wave type
1999+
///
2000+
/// This is used for testing IsXXXWave functions with actual wave references
2001+
static Function/WAVE GetEmptyWavesOfAllTypes()
2002+
2003+
Make/FREE/WAVE/N=10 waveRefs
2004+
2005+
// Numeric wave types
2006+
Make/FREE/D wvDouble
2007+
waveRefs[0] = wvDouble
2008+
SetDimLabel ROWS, 0, NT_FP64, waveRefs
2009+
2010+
Make/FREE/R wvSingle
2011+
waveRefs[1] = wvSingle
2012+
SetDimLabel ROWS, 1, NT_FP32, waveRefs
2013+
2014+
Make/FREE/I wvInt32
2015+
waveRefs[2] = wvInt32
2016+
SetDimLabel ROWS, 2, NT_I32, waveRefs
2017+
2018+
Make/FREE/W wvInt16
2019+
waveRefs[3] = wvInt16
2020+
SetDimLabel ROWS, 3, NT_I16, waveRefs
2021+
2022+
Make/FREE/B wvInt8
2023+
waveRefs[4] = wvInt8
2024+
SetDimLabel ROWS, 4, NT_I8, waveRefs
2025+
2026+
Make/FREE/I/U wvUInt32
2027+
waveRefs[5] = wvUInt32
2028+
SetDimLabel ROWS, 5, $"NT_I32 | NT_UNSIGNED", waveRefs
2029+
2030+
Make/FREE/W/U wvUInt16
2031+
waveRefs[6] = wvUInt16
2032+
SetDimLabel ROWS, 6, $"NT_I16 | NT_UNSIGNED", waveRefs
2033+
2034+
Make/FREE/B/U wvUInt8
2035+
waveRefs[7] = wvUInt8
2036+
SetDimLabel ROWS, 7, $"NT_I8 | NT_UNSIGNED", waveRefs
2037+
2038+
// Special wave types
2039+
Make/FREE/T wvText
2040+
waveRefs[8] = wvText
2041+
SetDimLabel ROWS, 8, TEXT_WAVE, waveRefs
2042+
2043+
Make/FREE/WAVE wvWave
2044+
waveRefs[9] = wvWave
2045+
SetDimLabel ROWS, 9, WAVE_WAVE, waveRefs
2046+
2047+
return waveRefs
2048+
End

0 commit comments

Comments
 (0)