import tensorflow as tf

class ASCIIToStringOp(tf.test.TestCase):
    def runTest(self):
        members = set(dir(self.__class__)) - set(dir(tf.test.TestCase))
        members.remove('runTest')
        rList = []
        for mem in members:
            rList.append(eval('self.' + mem + '()'))
        return rList
    def oneDTest(self):
        print "oneDTest..."
        asciis = tf.constant([97, 98, 99])
        asciis = tf.cast(asciis, tf.uint8)
        strings = tf.user_ops.ascii_to_string(asciis)
        with tf.Session() as sess:
            strs = sess.run([strings])
            for s in strs:
                print str(s) + '\n=============='

    def twoDTest(self):
        print "twoDTest..."
        asciis = tf.constant([ [ [97, 98, 99], [100, 101, 0] ], [ [0,0,0], [102, 103, 104] ] ])
        asciis = tf.cast(asciis, tf.uint8)
        strings = tf.user_ops.ascii_to_string(asciis)
        with tf.Session() as sess:
            strs = sess.run([strings])
            for s in strs:
                print str(s) + '\n=============='

    def encodeAndDecodeTest(self):
        print "encodeAndDecodeTest"
        strings = tf.constant([ [['a,', 'daasd', ''], ['d', '8*', '1']], [['yio', 'd', '=='], ['','','']] ])
        asciis = tf.user_ops.string_to_ascii(strings)
        strings_decoded = tf.user_ops.ascii_to_string(asciis)
        with tf.Session() as sess:
            strs = sess.run([asciis, strings_decoded])
            for s in strs:
                print str(s) + '\n=============='

if __name__ == "__main__":
    test = ASCIIToStringOp()
    testList = test.runTest()
