Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
takenori-y committed May 23, 2024
1 parent f17061e commit 13868d7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/test_onehot.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bats
# ------------------------------------------------------------------------ #
# Copyright 2021 SPTK Working Group #
# #
# 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. #
# ------------------------------------------------------------------------ #

sptk3=tools/sptk/bin
sptk4=bin
tmp=test_onehot

setup() {
mkdir -p $tmp
}

teardown() {
rm -rf $tmp
}

@test "onehot: compatibility" {
echo 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 | $sptk3/x2x +ad > $tmp/1
$sptk3/ramp -s -1 -e 3 | $sptk3/x2x +di | $sptk4/onehot -l 3 > $tmp/2
run $sptk4/aeq $tmp/1 $tmp/2
[ "$status" -eq 0 ]
}

@test "onehot: valgrind" {
$sptk3/nrand -l 20 -v 10 | x2x +di -r > $tmp/1
run valgrind $sptk4/onehot $tmp/1
[ "$(echo "${lines[-1]}" | sed -r 's/.*SUMMARY: ([0-9]*) .*/\1/')" -eq 0 ]
}

0 comments on commit 13868d7

Please sign in to comment.