From a751bf1f34852531caf0b5f80152e44fff020dd4 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Hühne Date: Wed, 6 Jun 2012 15:50:40 +0200 Subject: New validators and tests. --- lib/axlsx/util/validators.rb | 14 ++++++++++++++ test/util/tc_validators.rb | 19 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb index c7c97e78..f76c57ba 100644 --- a/lib/axlsx/util/validators.rb +++ b/lib/axlsx/util/validators.rb @@ -248,4 +248,18 @@ module Axlsx def self.validate_sheet_view_type(v) RestrictionValidator.validate :sheet_view_type, [:normal, :page_break_preview, :page_layout], v end + + # Requires that the value is a valid active pane type. + # valid types must be one of bottom_left, bottom_right, top_left, top_right + # @param [Any] v The value validated + def self.validate_active_pane_type(v) + RestrictionValidator.validate :active_pane_type, [:bottom_left, :bottom_right, :top_left, :top_right], v + end + + # Requires that the value is a valid split state type. + # valid types must be one of frozen, frozen_split, split + # @param [Any] v The value validated + def self.validate_split_state_type(v) + RestrictionValidator.validate :split_state_type, [:frozen, :frozen_split, :split], v + end end \ No newline at end of file diff --git a/test/util/tc_validators.rb b/test/util/tc_validators.rb index f5e11391..66138c54 100644 --- a/test/util/tc_validators.rb +++ b/test/util/tc_validators.rb @@ -141,6 +141,21 @@ class TestValidators < Test::Unit::TestCase assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style :other_symbol } assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 'page_layout' } assert_raise(ArgumentError) { Axlsx.validate_data_validation_error_style 0 } + + #active_pane_type + [:bottom_left, :bottom_right, :top_left, :top_right].each do |sym| + assert_nothing_raised { Axlsx.validate_active_pane_type sym } + end + assert_raise(ArgumentError) { Axlsx.validate_active_pane_type :other_symbol } + assert_raise(ArgumentError) { Axlsx.validate_active_pane_type 'bottom_left' } + assert_raise(ArgumentError) { Axlsx.validate_active_pane_type 0 } + + #split_state_type + [:frozen, :frozen_split, :split].each do |sym| + assert_nothing_raised { Axlsx.validate_split_state_type sym } + end + assert_raise(ArgumentError) { Axlsx.validate_split_state_type :other_symbol } + assert_raise(ArgumentError) { Axlsx.validate_split_state_type 'frozen_split' } + assert_raise(ArgumentError) { Axlsx.validate_split_state_type 0 } end -end - +end \ No newline at end of file -- cgit v1.2.3