Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Impressum test_sequence_output_stream.py

  Sprache: Python
 

#! /usr/bin/env python
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

import unittest
import uno

from org.libreoffice.unotest import UnoInProcess


class TestSequenceOutputStream(unittest.TestCase):
    """Test com.sun.star.io.SequenceOutputStream"""

    @classmethod
    def setUpClass(cls):
        cls._uno = UnoInProcess()
        cls._uno.setUp()

    @classmethod
    def tearDownClass(cls):
        cls._uno.tearDown()

    def setUp(self):
        self.data = uno.ByteSequence(b"some data")
        try:
            self.service_manager = self._uno.getContext().getServiceManager()
        except Exception:
            raise RuntimeError("Cannot create service factory!")
        if self.service_manager is None:
            raise RuntimeError("Cannot create service factory!")

    def test_stream(self):
        try:
            seq_output_stream = self.service_manager.createInstance(
                "com.sun.star.io.SequenceOutputStream"
            )
            seq_output_stream.writeBytes(self.data)

            # Append the same content once again
            seq_output_stream.writeBytes(self.data)

            written_bytes = seq_output_stream.getWrittenBytes()

            self.assertEqual(
                len(self.data) * 2,
                len(written_bytes),
                "SequenceOutputStream::getWrittenBytes() - wrong amount of bytes returned",
            )

            # create SequenceInputstream
            seq_input_stream = self.service_manager.createInstanceWithArguments(
                "com.sun.star.io.SequenceInputStream", (written_bytes,)
            )

            # read from the stream
            nbytes_read, read_bytes = seq_input_stream.readBytes(None, len(self.data) * 2 + 1)
            self.assertEqual(
                len(self.data) * 2,
                nbytes_read,
                "SequenceInputStream::readBytes() - "
                f"wrong amount of bytes returned {len(self.data) * 2} vs {nbytes_read}",
            )

            # close the streams
            seq_output_stream.closeOutput()
            seq_input_stream.closeInput()

            expected = uno.ByteSequence(self.data.value * 2)
            self.assertEqual(expected, written_bytes, "Written array not identical to original.")
            self.assertEqual(expected, read_bytes, "Read array not identical to original.")
        except Exception as e:
            self.fail(f"Exception: {e}")


if __name__ == "__main__":
    unittest.main()

# vim: set shiftwidth=4 softtabstop=4 expandtab:

Messung V0.5 in Prozent
C=92 H=97 G=94

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.23Bemerkung:  (vorverarbeitet am  2026-06-07) ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002