/* ----------------------------------------------------------------------------- Copyright 2021,2023 Kevin P. Barry Licensed 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. ----------------------------------------------------------------------------- */ // Author: Kevin P. Barry [ta0kira@gmail.com] testcase "SimpleQueue tests" { success TestChecker } unittest integrationTest { Int max <- 13 $ReadOnly[max]$ SimpleQueue queue <- SimpleQueue.default() traverse (`Counter.zeroIndexed` max -> Int value) { \ queue.size() `Matches:with` CheckValue:equals(value) \ queue.append(value) } traverse (`Counter.zeroIndexed` max -> Int value) { \ queue.size() `Matches:with` CheckValue:equals(max-value) \ queue.pop() `Matches:with` CheckValue:equals(value) } \ queue.size() `Matches:with` CheckValue:equals(0) } unittest duplicate { Int max <- 13 $ReadOnly[max]$ SimpleQueue queue <- `Counter.zeroIndexed` max `OrderH:copyTo` SimpleQueue.new() SimpleQueue copy <- queue.duplicate() \ queue.pop() \ queue.pop() \ queue.pop() $Hidden[queue]$ traverse (`Counter.zeroIndexed` max -> Int value) { \ copy.size() `Matches:with` CheckValue:equals(max-value) \ copy.pop() `Matches:with` CheckValue:equals(value) } \ copy.size() `Matches:with` CheckValue:equals(0) }