# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. require 'test_help' class TestIO < Test::Unit::TestCase DATAFILE = 'tmp/test.rb.avro' Schema = Avro::Schema def test_null check_default('"null"', "null", nil) end def test_boolean check_default('"boolean"', "true", true) check_default('"boolean"', "false", false) end def test_string check_default('"string"', '"foo"', "foo") end def test_bytes check_default('"bytes"', '"foo"', "foo") end def test_int check_default('"int"', "5", 5) end def test_long check_default('"long"', "9", 9) end def test_float check_default('"float"', "1.2", 1.2) end def test_double check_default('"double"', "1.2", 1.2) end def test_array array_schema = '{"type": "array", "items": "long"}' check_default(array_schema, "[1]", [1]) end def test_map map_schema = '{"type": "map", "values": "long"}' check_default(map_schema, '{"a": 1}', {"a" => 1}) end def test_record record_schema = < 11}) end def test_enum enum_schema = '{"type": "enum", "name": "Test","symbols": ["A", "B"]}' check_default(enum_schema, '"B"', "B") end def test_recursive recursive_schema = <