Backend: Add nsfw tests

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-04-30 15:42:13 +02:00
parent 953ca55483
commit 0c0bea5ed7

View file

@ -104,17 +104,25 @@ func TestIsSafe(t *testing.T) {
func TestNSFW(t *testing.T) { func TestNSFW(t *testing.T) {
porn := Labels{0, 0, 0.11, 0.88, 0} porn := Labels{0, 0, 0.11, 0.88, 0}
sexy := Labels{0, 0, 0.2, 0.59, 0.98} sexy := Labels{0, 0, 0.2, 0.59, 0.98}
max := Labels{0, 0.999, 0.1, 0.999, 0.999}
drawing := Labels{0.999, 0, 0, 0, 0}
hentai := Labels{0, 0.80, 0.2, 0, 0} hentai := Labels{0, 0.80, 0.2, 0, 0}
assert.Equal(t, true, porn.NSFW(ThresholdSafe)) assert.Equal(t, true, porn.NSFW(ThresholdSafe))
assert.Equal(t, true, sexy.NSFW(ThresholdSafe)) assert.Equal(t, true, sexy.NSFW(ThresholdSafe))
assert.Equal(t, true, hentai.NSFW(ThresholdSafe)) assert.Equal(t, true, hentai.NSFW(ThresholdSafe))
assert.Equal(t, false, drawing.NSFW(ThresholdSafe))
assert.Equal(t, true, max.NSFW(ThresholdSafe))
assert.Equal(t, true, porn.NSFW(ThresholdMedium)) assert.Equal(t, true, porn.NSFW(ThresholdMedium))
assert.Equal(t, true, sexy.NSFW(ThresholdMedium)) assert.Equal(t, true, sexy.NSFW(ThresholdMedium))
assert.Equal(t, false, hentai.NSFW(ThresholdMedium)) assert.Equal(t, false, hentai.NSFW(ThresholdMedium))
assert.Equal(t, false, drawing.NSFW(ThresholdMedium))
assert.Equal(t, true, max.NSFW(ThresholdMedium))
assert.Equal(t, false, porn.NSFW(ThresholdHigh)) assert.Equal(t, false, porn.NSFW(ThresholdHigh))
assert.Equal(t, false, sexy.NSFW(ThresholdHigh)) assert.Equal(t, false, sexy.NSFW(ThresholdHigh))
assert.Equal(t, false, hentai.NSFW(ThresholdHigh)) assert.Equal(t, false, hentai.NSFW(ThresholdHigh))
assert.Equal(t, false, drawing.NSFW(ThresholdHigh))
assert.Equal(t, true, max.NSFW(ThresholdHigh))
} }