You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.1 KiB

  1. # -*- cperl -*-
  2. # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; version 2 of the License.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. use Test::More qw(no_plan);
  17. use strict;
  18. use_ok("My::Options");
  19. my @tests=
  20. (
  21. [
  22. ['--binlog-format=row', '--loose-skip-innodb', '--binlog-format=ms'],
  23. ['--binlog-format=row', '--loose-skip-innodb', '--binlog-format=statement'],
  24. ['--binlog-format=statement']
  25. ],
  26. [
  27. ['--binlog-format=row', '--loose-skip-innodb', '--binlog-format=statement'],
  28. ['--binlog-format=row', '--loose-skip-innodb', '--binlog-format=mixed'],
  29. ['--binlog-format=mixed']
  30. ],
  31. [
  32. ['--binlog-format=row', '--loose-skip-innodb', '--binlog-format=mixed'],
  33. ['--binlog-format=row', '--loose-skip-innodb', '--binlog-format=statement'],
  34. ['--binlog-format=statement']
  35. ],
  36. [
  37. ['--binlog-format=mixed', '--loose-skip-innodb', '--binlog-format=row'],
  38. ['--binlog-format=statement', '--loose-skip-innodb', '--binlog-format=row'],
  39. [ ]
  40. ],
  41. [
  42. ['--binlog-format=row'],
  43. [ ],
  44. ['--binlog-format=default']
  45. ],
  46. [
  47. [ ],
  48. ['--binlog-format=row'],
  49. ['--binlog-format=row']
  50. ],
  51. [
  52. [ ],
  53. ['--max_binlog_size=1' ]
  54. ],
  55. [
  56. [ ],
  57. ['--max_binlog_size=default' ]
  58. ],
  59. [
  60. [ ],
  61. ['--max_binlog_size=1', '--binlog-format=row' ]
  62. ],
  63. [
  64. ['--binlog-format=statement' ],
  65. ['--max_binlog_size=1', '--binlog-format=row']
  66. ],
  67. [
  68. [ '--binlog-format=statement' ],
  69. ['--max_binlog_size=1' ]
  70. ],
  71. [
  72. [ '--binlog-format=statement' ],
  73. ['--max_binlog_size=1' ]
  74. ],
  75. [
  76. [ '--binlog-format=statement' ],
  77. ['--relay-log=/path/to/a/relay-log', '--binlog-format=row'],
  78. ['--relay-log=/path/to/a/relay-log', '--binlog-format=row' ]
  79. ],
  80. [
  81. [ '--binlog-format=statement' ],
  82. ['--relay-log=/path/to/a/relay-log', '--max_binlog_size=1'],
  83. ['--max_binlog_size=1', '--relay-log=/path/to/a/relay-log', '--binlog-format=default' ]
  84. ],
  85. [
  86. [ '--slow-query-log=0' ],
  87. [ '--slow-query-log' ],
  88. [ '--slow-query-log' ]
  89. ],
  90. );
  91. my $test_no= 0;
  92. foreach my $test (@tests){
  93. print "test", $test_no++, "\n";
  94. foreach my $opts (@$test){
  95. print My::Options::toStr("", @$opts);
  96. }
  97. my $from= $test->[0];
  98. my $to= $test->[1];
  99. my @result= My::Options::diff($from, $to);
  100. ok(My::Options::same(\@result, $test->[2]));
  101. if (!My::Options::same(\@result, $test->[2])){
  102. print "failed\n";
  103. print My::Options::toStr("result", @result);
  104. print My::Options::toStr("expect", @{$test->[2]});
  105. }
  106. print My::Options::toSQL(@result), "\n";
  107. print "\n";
  108. }