84 lines
1.8 KiB
Go
84 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"testing"
|
|
|
|
. "git.itmodulo.eu/go/hstl/processing"
|
|
. "git.itmodulo.eu/go/hstl/vars"
|
|
|
|
// . "github.com/deckarep/golang-set/v2"
|
|
. "github.com/jucardi/go-streams/v2/streams"
|
|
)
|
|
|
|
var str string = `# Malicious or purchaseable domains found in videogame manuals, title screens, or game driver/patch sites
|
|
127.0.0.1 acclaimsports.com
|
|
127.0.0.1 acclaimmaxsports.com
|
|
127.0.0.1 hip-games.com
|
|
127.0.0.1 thq.com.au
|
|
127.0.0.1 gp32.com
|
|
127.0.0.1 kidnkid.com
|
|
127.0.0.1 b-shooter.com # dupa
|
|
127.0.0.1 b-shooter.com
|
|
127.0.0.1 b-shooter.com
|
|
127.0.0.1 b-shooter.com
|
|
127.0.0.1 b-shooter.com
|
|
0.0.0.0 b-shooter.com
|
|
127.0.0.1 b-shooter.com
|
|
127.0.0.1 b-shooter.com
|
|
127.0.0.1 b-shooter.com
|
|
127.0.0.1 b-shooter.com
|
|
127.0.0.1 100-9.com`
|
|
|
|
// func TestPredicates(test *testing.T) {
|
|
|
|
// slc := strings.Split(str, "\n")
|
|
// set := treeset.NewWithStringComparator()
|
|
|
|
// var addtoset = func(i interface{}) { set.Add(i) }
|
|
|
|
// From(slc).
|
|
// Where(IsCommented).
|
|
// Select(SplitBySpaceOrTab).
|
|
// Where(MatchesInbuiltExpression).
|
|
// ForEach(addtoset)
|
|
|
|
// if set.Size() == 0 {
|
|
// test.FailNow()
|
|
// }
|
|
// set.Each(print)
|
|
|
|
// }
|
|
var PrintPredicate = func(word string) bool { fmt.Println("|", word, "|"); return false }
|
|
|
|
func TestPredicates(test *testing.T) {
|
|
|
|
slc := strings.Split(str, "\n")
|
|
|
|
var afterMapping = Map[string, string](
|
|
Map[string, string](
|
|
FromArray[string](slc, THREADS).
|
|
Except(IsCommented).
|
|
ToIterable(),
|
|
RmCommentsAfterRec).
|
|
Stream().
|
|
ToIterable(),
|
|
SplitBySpaceOrTab).
|
|
Stream().
|
|
SetThreads(THREADS).
|
|
Except(IsCommented).
|
|
Except(MatchesInbuiltExpression).
|
|
Except(IsEmpty).
|
|
Except(IsCommented).
|
|
ToList().Distinct().ToArray()
|
|
// ParallelForEach(addtoset, THREADS, true)
|
|
// var map2 = Map[string, string](afterMapping)
|
|
// x.Each(PrintPredicate)
|
|
for _, i := range afterMapping {
|
|
println(i)
|
|
}
|
|
println()
|
|
|
|
}
|