use Test::More;
-plan tests => 55;
+plan tests => 65;
use_ok('HTML::Form::Simple');
'multiple radios with custom values'
);
+{
+ # make sure arguments aren't modified
+ my @args = (foo => [0, 1], [0, {value => 1}], {name => 0, value => 1});
+ my @orgs = (foo => [0, 1], [0, {value => 1}], {name => 0, value => 1});
+ my @output = (
+ '<label><input id="foo_0" name="foo" type="radio" value="0"> 0</label>',
+ '<label><input checked id="foo_1" name="foo" type="radio" value="1"> 1</label>',
+ );
+
+ is_deeply(
+ [ $form->radio(@args) ],
+ \@output,
+ 'options var to radio'
+ );
+
+ is_deeply(
+ [ $form->check(@args) ],
+ [
+ '<label><input checked id="foo_1" name="foo" type="checkbox" value="1"> 0</label>',
+ '<label><input checked id="foo_2" name="foo" type="checkbox" value="2"> 1</label>',
+ ],
+ 'options var to check'
+ );
+
+ is(
+ scalar $form->radio(@args),
+ join('', @output),
+ 'options var again to radio'
+ );
+
+ is_deeply(\@args, \@orgs, 'options var unmodified');
+}
+
# check
is(
'various checkboxes'
);
+# defaults
+
+my $defform = HTML::Form::Simple->new({foo => '<">', '' => 'empty', 0 => 0});
+ok($defform, 'form with defaults');
+
+is(
+ $defform->hidden(''),
+ '<input name="" type="hidden" value="empty">',
+ 'hidden with default'
+);
+
+is(
+ $defform->hidden(undef),
+ '<input type="hidden">',
+ 'nameless hidden'
+);
+
+is(
+ $defform->text('foo'),
+ '<input id="foo" name="foo" type="text" value="<">">',
+ 'input with default'
+);
+
+is(
+ $defform->text('foo', {value => 'custom'}),
+ '<input id="foo" name="foo" type="text" value="custom">',
+ 'input with value and default'
+);
+
+is_deeply(
+ [ $defform->radio(0 => undef, [1, 0]) ],
+ [
+ '<input id="0_1" name="0" type="radio" value="1">',
+ '<input checked id="0_0" name="0" type="radio" value="0">',
+ ],
+ 'select with default'
+);
+
#TODO