1# ====================================================================
2#    Licensed to the Apache Software Foundation (ASF) under one
3#    or more contributor license agreements.  See the NOTICE file
4#    distributed with this work for additional information
5#    regarding copyright ownership.  The ASF licenses this file
6#    to you under the Apache License, Version 2.0 (the
7#    "License"); you may not use this file except in compliance
8#    with the License.  You may obtain a copy of the License at
9#
10#      http://www.apache.org/licenses/LICENSE-2.0
11#
12#    Unless required by applicable law or agreed to in writing,
13#    software distributed under the License is distributed on an
14#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15#    KIND, either express or implied.  See the License for the
16#    specific language governing permissions and limitations
17#    under the License.
18# ====================================================================
19
20require "test/unit"
21require "test/unit/assertions"
22
23module Test
24  module Unit
25    module Assertions
26
27      # make an intermediary assertion block handler
28      def _my_assert_block(&block)
29       if RUBY_VERSION > '1.9'
30         yield
31       else
32         _wrap_assertion do
33           yield
34         end
35       end
36      end
37
38      def assert_true(boolean, message=nil)
39        _my_assert_block do
40          assert_equal(true, boolean, message)
41        end
42      end
43
44      def assert_false(boolean, message=nil)
45        _my_assert_block do
46          assert_equal(false, boolean, message)
47        end
48      end
49
50      def assert_nested_sorted_array(expected, actual, message=nil)
51        _my_assert_block do
52          assert_equal(expected.collect {|elem| elem.sort},
53                       actual.collect {|elem| elem.sort},
54                       message)
55        end
56      end
57
58      def assert_equal_log_entries(expected, actual, message=nil)
59        _my_assert_block do
60          actual = actual.collect do |entry|
61            changed_paths = entry.changed_paths
62            changed_paths.each_key do |path|
63              changed_path = changed_paths[path]
64              changed_paths[path] = [changed_path.action,
65                                     changed_path.copyfrom_path,
66                                     changed_path.copyfrom_rev]
67            end
68            [changed_paths,
69             entry.revision,
70             entry.revision_properties.reject {|key, value| key == "svn:date"},
71             entry.has_children?]
72          end
73          assert_equal(expected, actual, message)
74        end
75      end
76    end
77  end
78end
79