Changeset 1409 for trunk/lang


Ignore:
Timestamp:
Apr 21, 2009, 11:40:07 AM (16 years ago)
Author:
gah
Message:

Fix encoding Tcl interface and tests.

Location:
trunk/lang/tcl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lang/tcl/src/RpEncodeTclInterface.cc

    r1384 r1409  
    146146        *flagsPtr = RPENC_Z;
    147147    } else {
    148         Tcl_AppendResult(interp, "bad order \"", string,
    149                  "\": should be breadthfirst, inorder, preorder, or postorder",
    150                  (char *)NULL);
     148        Tcl_AppendResult(interp, "bad value \"", string,
     149                 "\": should be b64, zb64, or z", (char *)NULL);
    151150        return TCL_ERROR;
    152151    }
     
    239238    {SWITCH_CUSTOM, "-as", "z|b64|zb64",
    240239        offsetof(DecodeSwitches, flags), 0, 0, &asSwitch},
    241     {SWITCH_BITMASK, "-raw", "",
     240    {SWITCH_BITMASK, "-noheader", "",
    242241        offsetof(DecodeSwitches, flags), 0, RPENC_RAW},
    243242    {SWITCH_END}
  • trunk/lang/tcl/tests/encode.test

    r1264 r1409  
    4747test is-1.2.0 {Rappture::encoding::is, 1 invalid subcommand} {
    4848    list [catch {Rappture::encoding::is binaryy "hi"} msg] $msg
    49 } {1 {bad option "binaryy": should be one of binary, encoded}}
     49} {1 {bad option "binaryy": should be binary or encoded}}
    5050
    5151test is-1.2.1 {Rappture::encoding::is, too many arguments} {
     
    118118test encode-2.0.0 {Rappture::encoding::encode, 0 arguments} {
    119119    list [catch {Rappture::encoding::encode} msg] $msg
    120 } {1 {wrong # args: should be "Rappture::encoding::encode ?-as z|b64|zb64? ?-no-header? ?--? <string>"}}
     120} {1 {wrong # args: should be "Rappture::encoding::encode ?-as z|b64|zb64? ?-noheader? ?--? string"}}
    121121
    122122test encode-2.1.0 {Rappture::encoding::encode, ascii string argument} {
     
    134134}}
    135135
    136 test encode-2.2.0 {Rappture::encoding::encode, -as flag blank value} {
     136test encode-2.2.0 {Rappture::encoding::encode, -as flag no value} {
    137137    list [catch {Rappture::encoding::encode -as} msg] $msg
    138 } {1 {bad value "": should be one of z, b64, zb64}}
     138} {1 {value for "-as" missing}}
    139139
    140140test encode-2.2.1 {Rappture::encoding::encode, -as flag bad value } {
    141141    list [catch {Rappture::encoding::encode -as zz} msg] $msg
    142 } {1 {bad value "zz": should be one of z, b64, zb64}}
     142} {1 {bad value "zz": should be b64, zb64, or z}}
    143143
    144144test encode-2.2.2 {Rappture::encoding::encode, -as flag correct value z} {
    145145    list [catch {Rappture::encoding::encode -as z} msg] $msg
    146 } {1 {wrong # args: should be "Rappture::encoding::encode ?-as z|b64|zb64? ?-no-header? ?--? <string>"}}
     146} {1 {wrong # args: should be "Rappture::encoding::encode ?-as z|b64|zb64? ?-noheader? ?--? string"}}
    147147
    148148test encode-2.2.3 {Rappture::encoding::encode, -as z w/ string} {
     
    158158test encode-2.2.5 {Rappture::encoding::encode with --} {
    159159    list [catch {Rappture::encoding::encode -hi} msg] $msg
    160 } {1 {bad option "-hi": should be -as, -no-header, --}}
     160} {1 {unknown switch "-hi"
     161following switches are available:
     162   -as z|b64|zb64
     163   -noheader }}
    161164
    162165test encode-2.2.6 {Rappture::encoding::encode with --} {
     
    174177test decode-3.0.0 {Rappture::encoding::decode, 0 arguments} {
    175178    list [catch {Rappture::encoding::decode} msg] $msg
    176 } {1 {wrong # args: should be "Rappture::encoding::decode ?-as z|b64|zb64? ?--? <string>"}}
     179} {1 {wrong # args: should be "Rappture::encoding::decode ?-as z|b64|zb64? ?--? string"}}
    177180
    178181test decode-3.1.0 {Rappture::encoding::decode, 1 arg, b64 encoded} {
     
    188191test decode-3.1.2 {Rappture::encoding::decode, 2 args} {
    189192    list [catch {Rappture::encoding::decode "hi" "bye"} msg] $msg
    190 } {1 {wrong # args: should be "Rappture::encoding::decode ?-as z|b64|zb64? ?--? <string>"}}
     193} {1 {wrong # args: should be "Rappture::encoding::decode ?-as z|b64|zb64? ?--? string"}}
    191194
    192195test decode-3.2.0 {Rappture::encoding::decode, -as flag, no value} {
    193196    list [catch {Rappture::encoding::decode -as} msg] $msg
    194 } {1 {bad value "": should be one of z, b64, zb64}}
     197} {1 {value for "-as" missing}}
    195198
    196199test decode-3.2.1 {Rappture::encoding::decode, -as flag, bad value} {
    197200    list [catch {Rappture::encoding::decode -as zz} msg] $msg
    198 } {1 {bad value "zz": should be one of z, b64, zb64}}
     201} {1 {bad value "zz": should be b64, zb64, or z}}
     202
     203# This test is wrong.  The -as z flag should either 1) be ignored and return
     204# "hi" (using the header) or 2) override the header and return an error when
     205# attempting to decompress the bogus string (see 3.2.2b)
    199206
    200207test decode-3.2.2 {Rappture::encoding::decode, -as flag, zb64 w/ string} {
     
    203210} {0 {@@RP-ENC:zb64
    204211H4sIAAAAAAAAA8vIBACsKpPYAgAAAA==}}
     212
     213test decode-3.2.2b {Rappture::encoding::decode, -as -noheader, zb64 w/ string} {
     214    set h "@@RP-ENC:zb64\nH4sIAAAAAAAAA8vIBACsKpPYAgAAAA=="
     215    list [catch {Rappture::encoding::decode -as z -noheader $h} msg] $msg
     216} {1 {Rappture::Buffer::do_decompress()
     217:
     218memory error while inflating data
     219Rappture::Buffer::do_decompress()
     220}}
    205221
    206222test decode-3.2.3 {Rappture::encoding::decode, -as flag, b64 w/ string} {
     
    216232test encode-3.2.5 {Rappture::encoding::decode with --} {
    217233    list [catch {Rappture::encoding::decode -hi} msg] $msg
    218 } {1 {bad option "-hi": should be -as, --}}
     234} {1 {unknown switch "-hi"
     235following switches are available:
     236   -as z|b64|zb64
     237   -noheader }}
     238
    219239
    220240test encode-3.2.6 {Rappture::encoding::decode with --} {
Note: See TracChangeset for help on using the changeset viewer.