package vectors_test

import (
	"fmt"
	"testing"

	"reflect"

	"github.com/acheong08/vectordb/vectors"
)

func TestEncoding(t *testing.T) {
	result, _ := vectors.Encode("1")
	expected := []float64{-0.27643221616744995, 0.012147089466452599, -0.3249976933002472, 0.3879562020301819, -0.4016413688659668, -0.4430374503135681, 0.9076811671257019, 0.294524610042572, -0.17874059081077576, -0.452308714389801, -0.2025914043188095, -0.7164658308029175, 0.33247900009155273, -0.1789475977420807, -0.29163986444473267, 0.1931614875793457, -0.5771744251251221, -0.600976824760437, -0.3427322506904602, -0.18998679518699646, -0.16423773765563965, -0.06377829611301422, 0.14894545078277588, 0.3478977084159851, -0.2791937589645386, -0.31767046451568604, 0.21091073751449585, 0.2483178824186325, 0.0419730469584465, -0.76731276512146, 0.05508681386709213, 0.0001249810156878084, 0.5614431500434875, -0.1832665652036667, 0.24302539229393005, -0.35243791341781616, -0.02300991676747799, -0.17958325147628784, -0.3677823543548584, 0.24519029259681702, 0.19841325283050537, -0.3426283299922943, 0.13741543889045715, -0.2521475553512573, 0.11553172767162323, -0.10817280411720276, -0.23790490627288818, 0.2833365201950073, 0.0019196073990315199, -0.2876407206058502, -0.14521555602550507, 0.2688080370426178, -0.31251031160354614, 0.04727693647146225, -0.026489559561014175, -0.4613376557826996, -0.5598061680793762, 0.2415987253189087, -0.1840384304523468, 0.03062809631228447, 0.5624005794525146, -0.48338088393211365, -0.3031523525714874, -0.011869510635733604, 0.17982129752635956, -0.24828645586967468, -0.0025177299976348877, -0.42874109745025635, 0.007493266370147467, 0.3199719786643982, -0.054929494857788086, -0.11889439821243286, -0.006890603806823492, -0.36479613184928894, 0.17030373215675354, -0.25707224011421204, 0.0002326369285583496, -0.2988075911998749, 0.42010295391082764, -0.14257436990737915, -0.1803625524044037, 0.04576393589377403, -0.27842968702316284, -0.051574110984802246, -0.2301609218120575, -0.1206914409995079, 0.10591211915016174, 0.5654901266098022, 0.4527541399002075, 0.49866995215415955, 0.21592532098293304, -0.22906243801116943, 0.7629324793815613, -0.10208259522914886, -0.3627719283103943, 0.2789173722267151, 0.4813753366470337, 0.0630851686000824, -0.017384987324476242, 1.551806926727295, -0.20183488726615906, 0.20478567481040955, 0.3749070167541504, 0.4243007302284241, -0.2484210729598999, 0.3092324733734131, -0.0667010173201561, 0.0630217045545578, 0.12822556495666504, 0.027841296046972275, -0.34671658277511597, -0.35246729850769043, 0.0719100683927536, 0.28297150135040283, -0.19063013792037964, 0.029396038502454758, 0.19842521846294403, 0.1498357206583023, -0.03128824755549431, -0.26815780997276306, 0.020133033394813538, 0.13756750524044037, 0.42437291145324707, 0.005361618008464575, -0.4824177920818329, -0.5480455756187439, -0.0447942316532135, -1.27340906295235e-32, 0.09637089818716049, 0.08135015517473221, -0.3845125138759613, 0.13168655335903168, 0.1830398440361023, 0.38477587699890137, -0.04989277571439743, -0.1057429164648056, -0.5584691762924194, 0.3271262049674988, -0.36851567029953003, 0.4538883566856384, 0.09097068756818771, 0.11110567301511765, 0.590599775314331, -0.38287636637687683, 0.6515322923660278, -0.03882385417819023, -0.039298947900533676, -0.27723681926727295, -0.31891411542892456, 0.3593364655971527, 0.16584506630897522, 0.23106782138347626, -0.16746166348457336, -0.0019728541374206543, -0.07587926834821701, -0.362332284450531, 0.11376358568668365, 0.05239655822515488, 0.12252222746610641, -0.06400734186172485, -0.44032880663871765, 0.03537974879145622, -0.3226054608821869, -0.09923764318227768, 0.5544156432151794, -0.0730983316898346, 0.16320250928401947, -0.22952699661254883, -0.5300419330596924, 0.032186247408390045, -0.22292505204677582, -0.10333569347858429, 0.26871681213378906, 0.21561460196971893, 0.39152106642723083, 0.2788543105125427, 0.13759693503379822, 0.8363131284713745, -0.32190096378326416, -0.04003874585032463, -0.6203657984733582, -0.13441000878810883, -0.3536408841609955, 0.10919719189405441, 0.17907246947288513, -0.06977389752864838, 0.2589544951915741, -0.18165263533592224, 0.45607757568359375, 0.09517796337604523, 0.15045908093452454, -0.31987226009368896, -0.3740770220756531, -0.13312287628650665, 0.0534384660422802, -0.09202202409505844, 0.15794043242931366, 0.15378837287425995, -0.566006064414978, 0.3185439109802246, 0.17078182101249695, -0.5090715289115906, 0.04611995071172714, -0.17531053721904755, 0.22314020991325378, 0.18713735044002533, -0.10994212329387665, 0.6594585180282593, -0.32823246717453003, 0.12671953439712524, -0.04438519477844238, 0.23373079299926758, 0.21633093059062958, 0.28480038046836853, 0.12786030769348145, -0.40848708152770996, 0.29228371381759644, 0.09430017322301865, -0.01272704266011715, -0.0637262687087059, 0.2111186981201172, -0.08911378681659698, -0.19054685533046722, 1.2066234248787787e-32, -0.3404960036277771, 0.43585604429244995, -0.49907660484313965, 0.5624316334724426, 0.06884244829416275, 0.3250494599342346, 0.2106335610151291, 0.20358526706695557, 0.013054112903773785, 0.2651307284832001, 0.05357421562075615, 0.12314774841070175, -0.17570875585079193, -0.2581668496131897, -0.10893021523952484, 0.31954333186149597, 0.4632832407951355, -0.14783379435539246, -0.3684050738811493, 0.3095598518848419, -0.1308925449848175, -0.0186893492937088, -0.31231850385665894, 0.35092347860336304, -0.40033429861068726, 0.6074199080467224, 0.26373228430747986, 0.30132293701171875, 0.17901042103767395, 0.33645111322402954, 0.4968094825744629, -0.17984849214553833, 0.26976633071899414, 0.07494073361158371, 0.06066720932722092, 0.1565745770931244, 0.6761990785598755, 0.08552210032939911, 0.16017021238803864, 0.32531964778900146, 0.7504765391349792, 0.178911492228508, 0.42563629150390625, 1.1518666744232178, -0.02576889656484127, -0.2753056287765503, -0.27326464653015137, 0.33759135007858276, -0.4089570641517639, 0.1710515022277832, -0.781883955001831, 0.30956873297691345, -0.8146889209747314, -0.25879472494125366, -0.3511199653148651, -0.3905317187309265, -0.10204046219587326, 0.26736897230148315, 0.5160077214241028, 0.025318186730146408, 0.10787322372198105, 0.5180118083953857, -0.0471150204539299, 0.3669174611568451, -0.05903434753417969, -0.00876714289188385, -0.1139584630727768, 0.03268377110362053, -0.4381839632987976, -0.1329282522201538, 0.42175793647766113, 0.016780763864517212, 0.09508597105741501, -0.4311647415161133, 0.086867555975914, 0.07698528468608856, -0.23941312730312347, -0.3957101106643677, 0.08064612746238708, -0.024794500321149826, -0.6526699066162109, 0.20782029628753662, -0.2594120502471924, -0.15155479311943054, 0.015614013187587261, -0.30316194891929626, 1.0218790769577026, 0.43905019760131836, -0.009114216081798077, -0.002337142825126648, 0.11916431784629822, 0.5592471957206726, 0.46849963068962097, -0.5792890787124634, -0.03199244290590286, -8.927312933337817e-08, 0.10117676109075546, 0.15947511792182922, -0.030042877420783043, -0.07089687883853912, 0.48931536078453064, 0.4088863134384155, -0.26715919375419617, 0.08546428382396698, 0.03136315196752548, -0.003815432544797659, 0.565248429775238, -0.17025373876094818, -0.11803951114416122, 0.2607514560222626, -0.09089937061071396, -0.35594475269317627, -0.4468514919281006, 0.23152637481689453, -0.12997229397296906, -0.4825522303581238, 0.2566356658935547, -0.24303492903709412, -0.15162712335586548, -0.538520336151123, -0.08334022015333176, 0.00463856291025877, -0.41100355982780457, 0.19463127851486206, 0.004016131162643433, -0.3092818558216095, 0.1657796949148178, 0.3839115500450134, 0.06575068831443787, -0.42632240056991577, 0.060120128095149994, -0.21927782893180847, 0.1364143341779709, 0.06188648194074631, 0.24638555943965912, 0.2767714858055115, 0.05723795294761658, -0.5481332540512085, 0.1861114501953125, -0.49135416746139526, -0.3824036717414856, -0.142450213432312, -0.5500744581222534, -0.12582549452781677, -0.1302560567855835, -0.20256471633911133, -0.5508807897567749, 0.10708989948034286, 0.2646474838256836, 0.21331731975078583, 0.23910707235336304, 0.2535947561264038, 0.05128886550664902, 0.15292036533355713, -0.15193799138069153, 0.2089819312095642, 0.6153635382652283, 0.4343991279602051, 0.06272102892398834, -0.039343200623989105}
	// check if result float64 is equal to expected float64
	if !reflect.DeepEqual(result, expected) {
		t.Errorf("Expected %v, got %v", expected, result)
	}
	fmt.Println("Size of result: ", len(result))

}

func TestEncodeMulti(t *testing.T) {
	result, _ := vectors.EncodeMulti([]string{"1"})
	expected, _ := vectors.Encode("1")
	if reflect.DeepEqual(result[0][0], expected) {
		t.Errorf("Expected %v,\n\n\n\n got %v", expected, result)
	}
}
