package main

import (
	"io/ioutil"
	"log"
	"regexp"
	"testing"

	"474420502.top/eson/gjson"
)

func TestTaskEx_Execute(t *testing.T) {
	rule := regexp.MustCompile(`\\"label\\"\:\\"广告\\"|\\"label_style\\"\:3`)
	data, err := ioutil.ReadFile("../sss.json")
	if err != nil {
		panic(err)
	}
	log.Println(rule.MatchString(string(data)))
	log.Println(gjson.Valid(string(data)))

	P := gjson.Parse(string(data))
	gADDate := P.Get(`data.#[content ~ @"label":"广告"@ ]#.content`)
	log.Println(gADDate.Exists(), gADDate.IsArray())

	if !(gADDate.Exists() && gADDate.IsArray()) {
		t.Error("path is error")
	}

	for _, result := range gADDate.Array() {
		if !gjson.Valid(result.Raw) {
			t.Error(result.String())
		}
		log.Println(result.String())
	}

}
