~ubuntu-branches/ubuntu/precise/judy/precise

« back to all changes in this revision

Viewing changes to test/Judy1LHCheck.c

  • Committer: Bazaar Package Importer
  • Author(s): Troy Heber
  • Date: 2007-05-21 15:07:50 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070521150750-khuc7e3iblyvi0a9
Tags: 1.0.5-1
* Fixed alignment issue, (Closes: #401124)
* Update packaging, policy, debhelper, etc.
* Removed old BIT cruft from rules
* Upstream has propper distclean target (Closes: #424425)

Show diffs side-by-side

added added

removed removed

Lines of Context:
181
181
    newseed &= RandomBit * 2 - 1;
182
182
    if (newseed == FirstSeed)
183
183
    {
184
 
        printf("End of LFSR, Total Population = %lu (0x%lx)\n", TotalPop, TotalPop);
 
184
        printf("Passed (End of LFSR) Judy1, JudyL, JudyHS tests for %lu numbers with <= %ld bits\n", TotalPop, BValue);
185
185
        exit(0);
186
186
    }
187
187
    return(newseed);
474
474
            TotalPop = 0;
475
475
        }
476
476
    }
477
 
    printf("Passed Judy1, JudyL and JudyHS tests\n");
 
477
    printf("Passed Judy1, JudyL, JudyHS tests for %lu numbers with <= %ld bits\n", nElms, BValue);
478
478
    exit(0);
479
479
}
480
480
 
511
511
        if (Rcode == 0)
512
512
            FAILURE("Judy1Set failed - DUP Index, population =", TotalPop);
513
513
 
 
514
#ifdef SKIPMACRO
 
515
        Rcode = Judy1Test(*J1, TstIndex);
 
516
#else
514
517
        J1T(Rcode, *J1, TstIndex);
 
518
#endif // SKIPMACRO
515
519
        if (Rcode != 1)
516
520
            FAILURE("Judy1Test failed - Index missing, population =", TotalPop);
517
521
 
529
533
//      Save Index in Value
530
534
        *PValue = TstIndex;
531
535
 
 
536
#ifdef SKIPMACRO
 
537
        PValue1 = (PWord_t)JudyLGet(*JL, TstIndex);
 
538
#else
532
539
        JLG(PValue1, *JL, TstIndex);
 
540
#endif // SKIPMACRO
533
541
        if (PValue != PValue1)
534
542
            FAILURE("JudyLGet failed - Index missing, population =", TotalPop);
535
543
 
602
610
        if (TstIndex < LowIndex)
603
611
            LowIndex = TstIndex;
604
612
 
 
613
#ifdef SKIPMACRO
 
614
        Rcode = Judy1Test(J1, TstIndex);
 
615
#else
605
616
        J1T(Rcode, J1, TstIndex);
 
617
#endif // SKIPMACRO
606
618
        if (Rcode != 1)
607
619
            FAILURE("Judy1Test Rcode != 1", Rcode);
608
620
 
 
621
#ifdef SKIPMACRO
 
622
        PValue = (PWord_t)JudyLGet(JL, TstIndex);
 
623
#else
609
624
        JLG(PValue, JL, TstIndex);
 
625
#endif // SKIPMACRO
610
626
        if (PValue == (Word_t *) NULL)
611
627
            FAILURE("JudyLGet ret PValue = NULL", 0L);
612
628
        if (*PValue != TstIndex)
704
720
        if (CountL == JERR)
705
721
            FAILURE("JudyLCount ret JERR", CountL);
706
722
 
707
 
        if (CountL != (elm + 1)) FAILURE("JLC at", elm);
 
723
        if (CountL != (elm + 1)) 
 
724
        {
 
725
            printf("CountL = %lu, elm +1 = %lu\n", CountL, elm + 1);
 
726
            FAILURE("JLC at", elm);
 
727
        }
708
728
 
709
729
        J1N(Rcode, J1, TstIndex);
710
730
    }
716
736
 
717
737
Word_t TestJudyNext(void *J1, void *JL, Word_t LowIndex, Word_t Elements)
718
738
{
719
 
    Word_t JLindex, J1index;
 
739
    Word_t JLindex, J1index, JPindex = 0;
720
740
    Word_t *PValue;
721
741
    Word_t elm;
722
742
    int Rcode;
736
756
        if (JLindex != J1index)
737
757
            FAILURE("JudyLNext & Judy1Next ret different PIndex at", elm);
738
758
 
 
759
        JPindex = J1index;              // save the last found index
 
760
 
739
761
        JLN(PValue, JL, JLindex);       // Get next one
740
762
        J1N(Rcode, J1, J1index);        // Get next one
741
763
    }
746
768
        FAILURE("Judy1Next Rcode != 1 =", Rcode);
747
769
 
748
770
//  perhaps a check should be done here -- if I knew what to expect.
749
 
    return(JLindex);            // return last one
 
771
    return(JPindex);            // return last one
750
772
}
751
773
 
752
774
 
797
819
    Word_t elm;
798
820
    Word_t JLindex, J1index;
799
821
    Word_t Seed1;
800
 
    int Rcode;          // Return code
 
822
    int Rcode1;         // Return code
 
823
    int RcodeL;         // Return code
801
824
 
802
825
//  Set 1st search to  ..
803
826
    Seed1 = LowIndex;
807
830
    {
808
831
        Word_t *PValue;
809
832
 
 
833
        if (pFlag) { printf("JNE: %8lu\t0x%lx\n", elm, JLindex); }
 
834
 
810
835
//      Find next Empty Index, JLindex is modified by JLNE
811
 
        JLNE(Rcode, JL, JLindex);       // Rcode = JudyLNextEmpty(JL, &JLindex, PJE0)
812
 
        if (Rcode != 1)
813
 
            FAILURE("JudyLNextEmpty Rcode != 1 =", Rcode);
814
 
 
815
 
        if (pFlag) { printf("JNE: %8lu\t0x%lx\n", elm, JLindex); }
 
836
        JLNE(RcodeL, JL, JLindex);      // Rcode = JudyLNextEmpty(JL, &JLindex, PJE0)
816
837
 
817
838
//      Find next Empty Index, J1index is modified by J1NE
818
 
        J1NE(Rcode, J1, J1index);       // Rcode = Judy1NextEmpty(J1, &J1index, PJE0)
819
 
        if (Rcode != 1)
820
 
            FAILURE("Judy1NextEmpty Rcode != 1 =", Rcode);
 
839
        J1NE(Rcode1, J1, J1index);      // Rcode = Judy1NextEmpty(J1, &J1index, PJE0)
 
840
        if ((Rcode1 != 1) || (RcodeL != 1))
 
841
        {
 
842
            printf("RcodeL = %d, Rcode1 = %d, Index1 = 0x%lx, IndexL = 0x%lx\n",
 
843
                    RcodeL, Rcode1, J1index, JLindex);
 
844
            FAILURE("Judy1NextEmpty Rcode != 1 =", Rcode1);
 
845
        }
821
846
 
822
847
        if (J1index != JLindex)
823
848
            FAILURE("JLNE != J1NE returned index at", elm);
824
 
 
825
 
        J1T(Rcode, J1, J1index);
826
 
        if (Rcode != 0)
 
849
#ifdef SKIPMACRO
 
850
        Rcode1 = Judy1Test(J1, J1index);
 
851
#else
 
852
        J1T(Rcode1, J1, J1index);
 
853
#endif // SKIPMACRO
 
854
        if (Rcode1 != 0)
827
855
            FAILURE("J1NE returned non-empty Index =", J1index);
828
856
 
 
857
#ifdef SKIPMACRO
 
858
        PValue = (PWord_t)JudyLGet(JL, JLindex);
 
859
#else
829
860
        JLG(PValue, JL, JLindex);
 
861
#endif // SKIPMACRO
830
862
        if (PValue != (Word_t *) NULL)
831
863
            FAILURE("JLNE returned non-empty Index =", JLindex);
832
864
        
848
880
    Word_t elm;
849
881
    Word_t JLindex, J1index;
850
882
    Word_t Seed1;
851
 
    int Rcode;
 
883
    int Rcode1;
 
884
    int RcodeL;
852
885
 
853
886
//  Set 1st search to  ..
854
887
    Seed1 = HighIndex;
857
890
    for (elm = 0; elm < Elements; elm++)
858
891
    {
859
892
        Word_t *PValue;
860
 
 
861
 
        J1PE(Rcode, J1, J1index);       // Rcode = Judy1PrevEmpty(J1, &J1index, PJE0)
862
 
        if (Rcode != 1)
863
 
            FAILURE("Judy1PrevEmpty Rcode != 1 =", Rcode);
864
 
 
865
 
        if (pFlag) { printf("JPE: %8lu\t0x%lx\n", elm, J1index); }
 
893
        Word_t JPIndex;
 
894
 
 
895
        JPIndex = J1index;
 
896
 
 
897
        if (pFlag) { printf("JPE: %8lu\t0x%lx\n", elm, JPIndex); }
 
898
 
 
899
        J1PE(Rcode1, J1, J1index);      // Rcode = Judy1PrevEmpty(J1, &J1index, PJE0)
866
900
 
867
901
//      Find next Empty Index, JLindex is modified by JLPE
868
 
        JLPE(Rcode, JL, JLindex);       // Rcode = JudyLPrevEmpty(JL, &JLindex, PJE0)
869
 
        if (Rcode != 1)
870
 
            FAILURE("JudyLPrevEmpty Rcode != 1 =", Rcode);
 
902
        JLPE(RcodeL, JL, JLindex);      // RcodeL = JudyLPrevEmpty(JL, &JLindex, PJE0)
 
903
        if ((RcodeL != 1) || (Rcode1 != 1))
 
904
        {
 
905
            printf("RcodeL = %d, Rcode1 = %d, Index1 = 0x%lx, IndexL = 0x%lx\n",
 
906
                    RcodeL, Rcode1, J1index, JLindex);
 
907
            FAILURE("Judy*PrevEmpty Rcode* != 1 =", RcodeL);
 
908
        }
871
909
 
872
910
        if (J1index != JLindex)
873
911
            FAILURE("JLPE != J1PE returned index at", elm);
874
912
 
875
 
        J1T(Rcode, J1, J1index);
876
 
        if (Rcode != 0)
 
913
#ifdef SKIPMACRO
 
914
        Rcode1 = Judy1Test(J1, J1index);
 
915
#else
 
916
        J1T(Rcode1, J1, J1index);
 
917
#endif // SKIPMACRO
 
918
        if (Rcode1 != 0)
877
919
            FAILURE("J1PE returned non-empty Index =", J1index);
878
920
 
 
921
#ifdef SKIPMACRO
 
922
        PValue = (PWord_t)JudyLGet(JL, JLindex);
 
923
#else
879
924
        JLG(PValue, JL, JLindex);
 
925
#endif // SKIPMACRO
880
926
        if (PValue != (Word_t *) NULL)
881
927
            FAILURE("JLPE returned non-empty Index =", JLindex);
882
928