Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tests for tdsTypeBoolean

  • Loading branch information...
commit 5d708063bd981e6ca32a50ed3a38fa644e966f75 1 parent d9a1703
@mnaberez authored
View
8 test/build_fixtures/README.txt
@@ -15,3 +15,11 @@ These fixtures were made by hand:
Fixtures type_1a_*.tdms are the same as type_0a_*.tdms but the
channel data type was edited from tdsTypeDoubleFloat (0x0A) to
tdsTypeDoubleFloatWithUnit (0x1A).
+
+LabVIEW 2010 saves booleans (tdsTypeBoolean) as 8-bit unsigned
+integers (tdsTypeU8). These fixtures were made by hand:
+
+ tdsTypeBoolean
+ Each type_21_*.tdms fixture was made by running the corresponding
+ VI but the channel data type was edited from tdsTypeU8 (0x05)
+ to tdsTypeBoolean (0x21).
View
BIN  test/build_fixtures/type_21_boolean_one_segment.vi
Binary file not shown
View
BIN  test/build_fixtures/type_21_boolean_three_segments.vi
Binary file not shown
View
BIN  test/build_fixtures/type_21_boolean_two_channels_one_segment.vi
Binary file not shown
View
BIN  test/fixtures/type_21_boolean_one_segment.tdms
Binary file not shown
View
BIN  test/fixtures/type_21_boolean_three_segments.tdms
Binary file not shown
View
BIN  test/fixtures/type_21_boolean_two_channels_one_segment.tdms
Binary file not shown
View
56 test/read_type_21_boolean_test.rb
@@ -0,0 +1,56 @@
+class ReadType21BooleanTest < Test::Unit::TestCase
+
+ def test_reads_one_boolean_channel_in_one_segment
+ filename = fixture_filename("type_21_boolean_one_segment")
+ doc = Tdms::File.parse(filename)
+
+ assert_equal 1, doc.segments.size
+ assert_equal 1, doc.segments[0].objects.size
+ assert_equal Tdms::DataType::Boolean::Id, doc.segments[0].objects[0].data_type_id
+
+ chan = doc.channels.find {|ch| ch.path == "/'boolean_group'/'boolean_channel'" }
+ assert_equal 2, chan.values.size
+
+ expected = [true, false]
+ assert_equal expected, chan.values.to_a
+ end
+
+ def test_reads_two_boolean_channels_in_one_segment
+ filename = fixture_filename("type_21_boolean_two_channels_one_segment")
+ doc = Tdms::File.parse(filename)
+
+ assert_equal 1, doc.segments.size
+ assert_equal 2, doc.segments[0].objects.size
+ assert_equal Tdms::DataType::Boolean::Id, doc.segments[0].objects[0].data_type_id
+ assert_equal Tdms::DataType::Boolean::Id, doc.segments[0].objects[1].data_type_id
+
+ chan = doc.channels.find {|ch| ch.path == "/'boolean_group'/'boolean_channel_a'" }
+ assert_equal 2, chan.values.size
+ expected = [true, false]
+ assert_equal expected, chan.values.to_a
+
+ chan = doc.channels.find {|ch| ch.path == "/'boolean_group'/'boolean_channel_b'" }
+ assert_equal 2, chan.values.size
+ expected = [false, true]
+ assert_equal expected, chan.values.to_a
+ end
+
+ def test_reads_one_boolean_channel_across_three_segments
+ filename = fixture_filename("type_21_boolean_three_segments")
+ doc = Tdms::File.parse(filename)
+
+ assert_equal 3, doc.segments.size
+ assert_equal 1, doc.segments[0].objects.size
+ assert_equal 1, doc.segments[1].objects.size
+ assert_equal 1, doc.segments[2].objects.size
+ assert_equal Tdms::DataType::Boolean::Id, doc.segments[0].objects[0].data_type_id
+ assert_equal Tdms::DataType::Boolean::Id, doc.segments[1].objects[0].data_type_id
+ assert_equal Tdms::DataType::Boolean::Id, doc.segments[2].objects[0].data_type_id
+
+ chan = doc.channels.find {|ch| ch.path == "/'boolean_group'/'boolean_channel'" }
+ assert_equal 6, chan.values.size
+ expected = [true, false, true, false, true, false]
+ assert_equal expected, chan.values.to_a
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.